initial commit
[chaz/homebank2ledger] / lib / App / HomeBank2Ledger / Util.pm
1 package App::HomeBank2Ledger::Util;
2 # ABSTRACT: Miscellaneous utility functions
3
4 use warnings;
5 use strict;
6
7 use Exporter qw(import);
8
9 our $VERSION = '9999.999'; # VERSION
10
11 our @EXPORT_OK = qw(commify);
12
13 =func commify
14
15 $commified = commify($num);
16 $commified = commify($num, $comma_char);
17
18 Just another commify subroutine.
19
20 =cut
21
22 sub commify {
23 my $num = shift;
24 my $comma = shift || ',';
25
26 my $str = reverse $num;
27 $str =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1$comma/g;
28
29 return scalar reverse $str;
30 }
31
32 1;
This page took 0.033544 seconds and 4 git commands to generate.