line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::Perl; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
753
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
92
|
|
7
|
1
|
|
|
1
|
|
813
|
use Template::Plugin; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
27
|
|
8
|
1
|
|
|
1
|
|
8
|
use base qw( Template::Plugin ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
9
|
1
|
|
|
1
|
|
5
|
use vars qw( $AUTOLOAD $VERSION ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
466
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$VERSION = '0.06'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$Data::Dumper::Indent = 0; |
14
|
|
|
|
|
|
|
*throw = \&Template::Plugin::Perl::throw; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
18
|
|
|
18
|
1
|
117488
|
my ($class, $context, $params) = @_; |
18
|
18
|
|
|
|
|
134
|
bless { |
19
|
|
|
|
|
|
|
_context => $context, |
20
|
|
|
|
|
|
|
}, $class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $entered = 0; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub AUTOLOAD { |
26
|
41
|
|
|
41
|
|
1418
|
my $self = shift; |
27
|
41
|
|
|
|
|
75
|
my $method = $AUTOLOAD; |
28
|
|
|
|
|
|
|
#warn "$method"; |
29
|
|
|
|
|
|
|
|
30
|
41
|
|
|
|
|
193
|
$method =~ s/.*:://; |
31
|
41
|
50
|
|
|
|
137
|
return if $method eq 'DESTROY'; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#warn "\@_ = @_\n"; |
34
|
41
|
50
|
|
|
|
101
|
if ($entered == 1) { |
35
|
0
|
|
|
|
|
0
|
die("$method not found\n"); |
36
|
|
|
|
|
|
|
} |
37
|
41
|
|
|
|
|
60
|
my @args; |
38
|
41
|
|
|
|
|
88
|
foreach my $arg (@_) { |
39
|
57
|
|
|
|
|
332
|
my $code = Data::Dumper->Dump([$arg], ['args']); |
40
|
57
|
|
|
|
|
3094
|
$code =~ s/^\s*\$args\s*=\s*(.*);\s*$/$1/s; |
41
|
57
|
|
|
|
|
115
|
$code =~ s/^\[(.*)\]\s*$/$1/s; |
42
|
57
|
|
|
|
|
169
|
push @args, $code; |
43
|
|
|
|
|
|
|
} |
44
|
41
|
|
|
|
|
129
|
my $code = "$method(".join(',', @args).")"; |
45
|
|
|
|
|
|
|
#warn "code: $code\n"; |
46
|
41
|
|
|
|
|
70
|
$entered = 1; |
47
|
41
|
|
|
|
|
3018
|
my @retval = eval $code; |
48
|
41
|
|
|
|
|
114
|
$entered = 0; |
49
|
41
|
50
|
|
|
|
133
|
if ($@) { |
50
|
0
|
|
|
|
|
0
|
$self->throw("Perl built-in function error: $@"); |
51
|
|
|
|
|
|
|
} |
52
|
41
|
50
|
|
|
|
101
|
if (!@retval) { return (); } |
|
0
|
|
|
|
|
0
|
|
53
|
41
|
100
|
|
|
|
109
|
if (@retval == 1) { $retval[0] } |
|
36
|
|
|
|
|
250
|
|
54
|
5
|
|
|
|
|
59
|
else { \@retval }; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub throw { |
58
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
59
|
0
|
|
|
|
|
0
|
die (Template::Exception->new('Plugin Perl', join(', ', @_))); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub pow { |
63
|
1
|
|
|
1
|
1
|
37
|
shift; |
64
|
1
|
|
|
|
|
18
|
return $_[0] ** $_[1]; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
__END__ |