line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TipJar::Template::fill; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5983
|
use vars qw/$VERSION/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
350
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$VERSION = '0.01'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub import{ |
8
|
2
|
|
|
2
|
|
11
|
shift; # lose package name |
9
|
2
|
|
|
|
|
6
|
my %args = @_; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
100
|
|
|
14
|
$args{fill} ||= 'fill'; |
12
|
2
|
|
100
|
|
|
7
|
$args{hashref} ||= \%{caller().'::'.$args{fill}}; |
|
1
|
|
|
|
|
10
|
|
13
|
2
|
|
66
|
|
|
7
|
$args{regex} ||= qr{\[(\w+)\]}; |
14
|
|
|
|
|
|
|
|
15
|
2
|
100
|
|
|
|
5
|
if($args{_args}){ |
16
|
1
|
|
|
|
|
1
|
*{caller().'::'.$args{fill}.'_args'} = \%args; |
|
1
|
|
|
|
|
5
|
|
17
|
1
|
|
|
|
|
4
|
*{caller().'::'.$args{fill}} = |
18
|
|
|
|
|
|
|
sub($;$){ |
19
|
2
|
|
|
2
|
|
2
|
my $result = $_[0]; |
20
|
2
|
|
|
|
|
42
|
$result =~ s/$args{regex}/$args{hashref}->{$1}/g; |
21
|
2
|
|
|
|
|
10
|
$result; |
22
|
1
|
|
|
|
|
3
|
}; |
23
|
1
|
|
|
|
|
1654
|
return; |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
4
|
*{caller().'::'.$args{fill}} = |
|
1
|
|
|
|
|
88
|
|
27
|
|
|
|
|
|
|
makesub(@args{qw/regex hashref/}); |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub makesub{ |
31
|
1
|
|
|
1
|
0
|
1
|
my ($regex, $default_hr) = @_; |
32
|
|
|
|
|
|
|
sub($;$){ |
33
|
2
|
|
|
2
|
|
94
|
my ($result, $hr) = @_; |
34
|
2
|
|
66
|
|
|
11
|
$hr ||= $default_hr; |
35
|
2
|
|
|
|
|
20
|
$result =~ s/$regex/$hr->{$1}/g; |
36
|
2
|
|
|
|
|
11
|
$result; |
37
|
1
|
|
|
|
|
4
|
}; |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
__END__ |