]> Dogcows Code - chaz/homebank2ledger/blob - lib/App/HomeBank2Ledger/Util.pm
9f5b853f27dd3a9d505dcd008c3acf2428339d83
[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 rtrim);
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 =func rtrim
33
34 $trimmed_str = rtrim($str);
35
36 Right-trim a string.
37
38 =cut
39
40 sub rtrim {
41 my $str = shift;
42 $str =~ s/\h+$//;
43 return $str;
44 }
45
46 1;
This page took 0.03269 seconds and 4 git commands to generate.