line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Like::Stash; |
2
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
75
|
use strict; |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
20317
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new { |
6
|
103
|
|
|
103
|
0
|
161
|
my $class = shift; |
7
|
103
|
|
50
|
|
|
447
|
my $args = shift || {}; |
8
|
|
|
|
|
|
|
|
9
|
103
|
|
|
|
|
433
|
return bless $args, $class; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub set { |
13
|
114
|
|
|
114
|
0
|
183
|
my $self = shift; |
14
|
114
|
|
|
|
|
144
|
my $key = shift; |
15
|
114
|
|
|
|
|
124
|
my $val = shift; |
16
|
114
|
50
|
|
|
|
279
|
if (@_) { |
17
|
0
|
|
|
|
|
0
|
return $_[0]->{ $key } = $val; |
18
|
|
|
|
|
|
|
} |
19
|
114
|
|
|
|
|
306
|
$self->{ $key } = $val; |
20
|
114
|
|
|
|
|
265
|
return ; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub update { |
24
|
206
|
|
|
206
|
0
|
260
|
my $self = shift; |
25
|
206
|
|
|
|
|
230
|
my $vars = shift; |
26
|
206
|
|
|
|
|
229
|
@{ $self }{ keys %{ $vars } } = values %{ $vars }; |
|
206
|
|
|
|
|
885
|
|
|
206
|
|
|
|
|
391
|
|
|
206
|
|
|
|
|
481
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub clone { |
30
|
0
|
|
|
0
|
0
|
0
|
bless { %{ $_[0] } }, 'Template::Like::Stash'; |
|
0
|
|
|
|
|
0
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub get { |
34
|
157
|
|
|
157
|
0
|
238
|
my $self = shift; |
35
|
157
|
|
|
|
|
349
|
my $key = shift; |
36
|
|
|
|
|
|
|
|
37
|
157
|
50
|
|
|
|
501
|
if ( $key=~/([^\.]+)\.(.*)/ ) { |
38
|
0
|
0
|
|
|
|
0
|
return unless exists $self->{ $1 }; |
39
|
0
|
|
|
|
|
0
|
return $self->next( $self->{ $1 }, $2, @_ ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
157
|
100
|
|
|
|
916
|
return unless exists $self->{ $key }; |
43
|
|
|
|
|
|
|
|
44
|
146
|
|
|
|
|
212
|
my $ret = $self->{ $key }; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# execute code ref. |
47
|
146
|
50
|
|
|
|
604
|
if ( UNIVERSAL::isa($ret, 'CODE') ) { |
48
|
0
|
|
|
|
|
0
|
return $ret->( @_ ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
146
|
|
|
|
|
3145
|
return $ret; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub next { |
55
|
43
|
|
|
43
|
0
|
56
|
my $self = shift; |
56
|
43
|
|
|
|
|
52
|
my $val = shift; |
57
|
43
|
|
|
|
|
48
|
my $key = shift; |
58
|
|
|
|
|
|
|
|
59
|
43
|
100
|
100
|
|
|
295
|
if ( UNIVERSAL::can($val, $key) ) { |
|
|
100
|
66
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
60
|
18
|
|
|
|
|
60
|
$val = $val->$key( @_ ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
elsif ( UNIVERSAL::isa($val, "HASH") && exists $val->{$key} ) { |
64
|
20
|
|
|
|
|
36
|
$val = $val->{$key}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
elsif ( UNIVERSAL::isa($val, 'ARRAY') && $key=~/^\d+$/ ) { |
68
|
0
|
|
|
|
|
0
|
$val = $val->[$key]; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
elsif ( Template::Like::VMethods->can($key, $val) ) { |
72
|
4
|
|
|
|
|
15
|
$val = Template::Like::VMethods->exec($key, $val, @_); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
else { |
76
|
1
|
|
|
|
|
33
|
return ; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# execute code ref. |
80
|
42
|
50
|
|
|
|
260
|
if ( UNIVERSAL::isa($val, 'CODE') ) { |
81
|
0
|
|
|
|
|
0
|
return $val->(); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
42
|
|
|
|
|
545
|
return $val; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |