]> Dogcows Code - chaz/homebank2ledger/blob - lib/App/HomeBank2Ledger/Util.pm
Version 0.001
[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 = '0.001'; # VERSION
10
11 our @EXPORT_OK = qw(commify rtrim);
12
13
14 sub commify {
15 my $num = shift;
16 my $comma = shift || ',';
17
18 my $str = reverse $num;
19 $str =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1$comma/g;
20
21 return scalar reverse $str;
22 }
23
24
25 sub rtrim {
26 my $str = shift;
27 $str =~ s/\h+$//;
28 return $str;
29 }
30
31 1;
32
33 __END__
34
35 =pod
36
37 =encoding UTF-8
38
39 =head1 NAME
40
41 App::HomeBank2Ledger::Util - Miscellaneous utility functions
42
43 =head1 VERSION
44
45 version 0.001
46
47 =head1 FUNCTIONS
48
49 =head2 commify
50
51 $commified = commify($num);
52 $commified = commify($num, $comma_char);
53
54 Just another commify subroutine.
55
56 =head2 rtrim
57
58 $trimmed_str = rtrim($str);
59
60 Right-trim a string.
61
62 =head1 BUGS
63
64 Please report any bugs or feature requests on the bugtracker website
65 L<https://github.com/chazmcgarvey/homebank2ledger/issues>
66
67 When submitting a bug or request, please include a test-file or a
68 patch to an existing test-file that illustrates the bug or desired
69 feature.
70
71 =head1 AUTHOR
72
73 Charles McGarvey <chazmcgarvey@brokenzipper.com>
74
75 =head1 COPYRIGHT AND LICENSE
76
77 This software is Copyright (c) 2019 by Charles McGarvey.
78
79 This is free software, licensed under:
80
81 The MIT (X11) License
82
83 =cut
This page took 0.036386 seconds and 4 git commands to generate.