line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::TallyMarks; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
91918
|
use 5.006; |
|
2
|
|
|
|
|
7
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
54
|
|
5
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
68
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
672
|
use parent 'Template::Plugin::Filter'; |
|
2
|
|
|
|
|
504
|
|
|
2
|
|
|
|
|
8
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Template::Plugin::TallyMarks - Convert numbers to tally marks. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 0.01 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
The module implements a filter that changes a number into tally marks. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Template; |
27
|
|
|
|
|
|
|
my $tt = 'Template'->new; |
28
|
|
|
|
|
|
|
$tt->process( \ '[% USE TallyMarks %][% n | tally_marks %]', |
29
|
|
|
|
|
|
|
{ n => 12 }, |
30
|
|
|
|
|
|
|
\ my $result ); |
31
|
|
|
|
|
|
|
print $result; # |||| |||| || |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 Filters |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 tally_marks |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Transforms the input parameter into tally marks. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub init { |
42
|
1
|
|
|
1
|
0
|
61
|
my $self = shift; |
43
|
1
|
|
|
|
|
5
|
$self->install_filter('tally_marks'); |
44
|
1
|
|
|
|
|
46
|
return $self |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub filter { |
49
|
8
|
|
|
8
|
0
|
18143
|
my ($self, $n) = @_; |
50
|
8
|
|
66
|
|
|
103
|
return join ' ', |
51
|
|
|
|
|
|
|
('||||') x int($n / 5), |
52
|
|
|
|
|
|
|
('|' x ($n % 5)) || () |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 AUTHOR |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
E. Choroba, C<< >> |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 BUGS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
62
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
63
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SUPPORT |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
perldoc Template::Plugin::TallyMarks |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
You can also look for information at: |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=over 4 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item * MetaCPAN |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
L |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item * GitHub Repository |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
L |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
L |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * Search CPAN |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
L |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=back |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Thanks to Mohammad S Anwar for contribution. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Copyright 2016 E. Choroba. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
104
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
105
|
|
|
|
|
|
|
copy of the full license at: |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
110
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
111
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
112
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
115
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
116
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
119
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
122
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
123
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
124
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
125
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
126
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
127
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
128
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
131
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
132
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
133
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
134
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
135
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
136
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
137
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
__PACKAGE__ |