| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::Template::LocalVars::Package; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1735
|
use Package::Stash; |
|
|
3
|
|
|
|
|
33300
|
|
|
|
3
|
|
|
|
|
152
|
|
|
4
|
3
|
|
|
3
|
|
1526
|
use Symbol qw[ delete_package ]; |
|
|
3
|
|
|
|
|
4317
|
|
|
|
3
|
|
|
|
|
246
|
|
|
5
|
3
|
|
|
3
|
|
1875
|
use Storable qw[ dclone ]; |
|
|
3
|
|
|
|
|
18672
|
|
|
|
3
|
|
|
|
|
1993
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my $pkgid = 0; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=begin quiet_pod_coverage |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head2 new |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=end quiet_pod_coverage |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
|
18
|
|
|
|
|
|
|
|
|
19
|
12
|
|
|
12
|
1
|
28
|
my ( $class, $orig ) = @_; |
|
20
|
|
|
|
|
|
|
|
|
21
|
12
|
|
|
|
|
82
|
my $self = bless \( __PACKAGE__ . '::Q' . $pkgid++ ), $class; |
|
22
|
|
|
|
|
|
|
|
|
23
|
12
|
|
|
|
|
90
|
$self->_copy_package( $orig ); |
|
24
|
|
|
|
|
|
|
|
|
25
|
12
|
|
|
|
|
47
|
return $self; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=begin quiet_pod_coverage |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 pkg |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=end quiet_pod_coverage |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
48
|
|
|
48
|
1
|
80
|
sub pkg { ${ $_[0] } } |
|
|
48
|
|
|
|
|
230
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub DESTROY { |
|
39
|
|
|
|
|
|
|
|
|
40
|
12
|
|
|
12
|
|
22623
|
my $self = shift; |
|
41
|
|
|
|
|
|
|
|
|
42
|
12
|
|
|
|
|
41
|
delete_package( $self->pkg ); |
|
43
|
|
|
|
|
|
|
|
|
44
|
12
|
|
|
|
|
2370
|
return; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#<<< no perltidy |
|
48
|
|
|
|
|
|
|
# ignore dclone warnings; $Storable::forgive_me set below |
|
49
|
|
|
|
|
|
|
my @Map = ( |
|
50
|
|
|
|
|
|
|
[ HASH => '%' => sub {local $SIG{__WARN__} = sub { }; dclone( shift );}], |
|
51
|
|
|
|
|
|
|
[ ARRAY => '@' => sub {local $SIG{__WARN__} = sub { }; dclone( shift );}], |
|
52
|
|
|
|
|
|
|
[ CODE => '&' => sub { shift } ], |
|
53
|
|
|
|
|
|
|
[ SCALAR => '$' => sub { ${ $_[0] } if 'SCALAR' eq ref $_[0] } ], |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
#>>> no perltidy |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _copy_package { |
|
58
|
|
|
|
|
|
|
|
|
59
|
12
|
|
|
12
|
|
33
|
my ( $self, $src_pkg ) = @_; |
|
60
|
|
|
|
|
|
|
|
|
61
|
12
|
|
|
|
|
158
|
my $src = Package::Stash->new( $src_pkg ); |
|
62
|
12
|
|
|
|
|
45
|
my $dst = Package::Stash->new( $self->pkg ); |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# can't use the globs directly, but because scalar slots in |
|
65
|
|
|
|
|
|
|
# globs will always return a reference (at least as of Perl |
|
66
|
|
|
|
|
|
|
# 5.20.1) even if unused. that means we'd create extra scalars |
|
67
|
|
|
|
|
|
|
# where there were none. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# we don't care if dclone can't store things we don't care |
|
70
|
|
|
|
|
|
|
# about (like GLOBS buried in a hash or an array) |
|
71
|
12
|
|
|
|
|
34
|
local $Storable::forgive_me = 1; |
|
72
|
|
|
|
|
|
|
|
|
73
|
12
|
|
|
|
|
30
|
for my $map ( @Map ) { |
|
74
|
|
|
|
|
|
|
|
|
75
|
48
|
|
|
|
|
121
|
my ( $type, $sigil, $convert ) = @$map; |
|
76
|
48
|
|
|
|
|
646
|
my $symbols = $src->get_all_symbols( $type ); |
|
77
|
|
|
|
|
|
|
|
|
78
|
48
|
|
|
|
|
206
|
while ( my ( $var, $value ) = each %$symbols ) { |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# don't clone |
|
81
|
|
|
|
|
|
|
# * anything which looks like a package stash. |
|
82
|
|
|
|
|
|
|
# * the special _ variable, which causes things to segv |
|
83
|
|
|
|
|
|
|
# on some Perls when the package is deleted. |
|
84
|
330
|
50
|
33
|
|
|
1183
|
next if $var =~ /::$/ or $var eq '_'; |
|
85
|
|
|
|
|
|
|
|
|
86
|
330
|
50
|
|
|
|
515
|
eval { |
|
87
|
330
|
|
|
|
|
666
|
$dst->add_symbol( $sigil . $var, $convert->( $value ) ); |
|
88
|
330
|
|
|
|
|
1551
|
1; |
|
89
|
|
|
|
|
|
|
} or die( "error adding $sigil$var: $@\n" ); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 NAME |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Text::Template::LocalVars::Package - manage clone of a template variable package |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Don't do anything with this |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This is a private module for use by L. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 AUTHOR |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Diab Jerius, C<< >> |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Copyright (C) 2014 Smithsonian Astrophysical Observatory |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Copyright (C) 2014 Diab Jerius |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Text::Template::LocalVars is free software: you can redistribute it |
|
121
|
|
|
|
|
|
|
and/or modify it under the terms of the GNU General Public License as |
|
122
|
|
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the |
|
123
|
|
|
|
|
|
|
License, or (at your option) any later version. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
|
126
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
127
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
128
|
|
|
|
|
|
|
GNU General Public License for more details. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
|
131
|
|
|
|
|
|
|
along with this program. If not, see . |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|