| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Exporter::Easy; |
|
2
|
|
|
|
|
|
|
$Exporter::Easy::VERSION = '0.17'; |
|
3
|
2
|
|
|
2
|
|
32461
|
use 5.006; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
77
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
63
|
|
|
5
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
56
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
|
8
|
2
|
|
|
2
|
|
13
|
use vars; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
1522
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub import |
|
12
|
|
|
|
|
|
|
{ |
|
13
|
13
|
|
|
13
|
|
16187
|
my $pkg = shift; |
|
14
|
|
|
|
|
|
|
|
|
15
|
13
|
|
|
|
|
31
|
unshift(@_, scalar caller); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# must goto or we lose the use vars functionality |
|
18
|
|
|
|
|
|
|
|
|
19
|
13
|
|
|
|
|
40
|
goto &set_export_vars; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub set_export_vars |
|
23
|
|
|
|
|
|
|
{ |
|
24
|
|
|
|
|
|
|
# this handles setting up all of the EXPORT variables in the callers |
|
25
|
|
|
|
|
|
|
# package. It gives a nice way of creating tags, allows you to use tags |
|
26
|
|
|
|
|
|
|
# when defining @EXPORT, @EXPORT_FAIL and other in tags. It also takes |
|
27
|
|
|
|
|
|
|
# care of @EXPORT_OK. |
|
28
|
|
|
|
|
|
|
|
|
29
|
15
|
|
|
15
|
0
|
59
|
my ($callpkg, %args) = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
15
|
|
|
|
|
16
|
my %could_export; # symbols that could be exported |
|
32
|
|
|
|
|
|
|
my @will_export; # symbols that will be exported by default |
|
33
|
0
|
|
|
|
|
0
|
my @fail; # symbols that should be tested before export |
|
34
|
0
|
|
|
|
|
0
|
my @ok_only; # the symbols that are ok to export |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
my %tags; # will contain a ref hash of all tags |
|
37
|
|
|
|
|
|
|
|
|
38
|
15
|
|
|
|
|
36
|
@_ = (); # we'll be using this for vars to be use vars'd |
|
39
|
|
|
|
|
|
|
|
|
40
|
15
|
50
|
66
|
|
|
57
|
if ($args{OK_ONLY} and $args{OK}) |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
0
|
|
|
|
|
0
|
nice_die("Can't use OK_ONLY and OK together"); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
15
|
100
|
|
|
|
39
|
my $isa = exists $args{ISA} ? delete $args{ISA} : 1; |
|
46
|
15
|
100
|
|
|
|
30
|
my $vars = exists $args{VARS} ? delete $args{VARS} : 1; |
|
47
|
|
|
|
|
|
|
|
|
48
|
15
|
100
|
|
|
|
52
|
if (my $tag_data = delete $args{'TAGS'}) |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
7
|
50
|
|
|
|
21
|
nice_die("TAGS must be a reference to an array") unless ref($tag_data) eq 'ARRAY'; |
|
51
|
|
|
|
|
|
|
|
|
52
|
7
|
|
|
|
|
17
|
add_tags($tag_data, \%tags); |
|
53
|
|
|
|
|
|
|
|
|
54
|
7
|
|
|
|
|
14
|
@could_export{map {@$_} values %tags} = (); |
|
|
17
|
|
|
|
|
49
|
|
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
15
|
100
|
|
|
|
257
|
if (my $export = delete $args{'EXPORT'}) |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
6
|
50
|
|
|
|
17
|
nice_die("EXPORT must be a reference to an array") |
|
60
|
|
|
|
|
|
|
unless ref($export) eq 'ARRAY'; |
|
61
|
|
|
|
|
|
|
|
|
62
|
6
|
|
|
|
|
28
|
@will_export = eval { expand_tags($export, \%tags) }; |
|
|
6
|
|
|
|
|
15
|
|
|
63
|
6
|
100
|
|
|
|
23
|
nice_die("$@while building the EXPORT list in $callpkg") if $@; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
14
|
100
|
|
|
|
35
|
if (my $ok = delete $args{'OK'}) |
|
67
|
|
|
|
|
|
|
{ |
|
68
|
4
|
50
|
|
|
|
11
|
nice_die("OK must be a reference to a array") unless ref($ok) eq 'ARRAY'; |
|
69
|
|
|
|
|
|
|
|
|
70
|
4
|
|
|
|
|
5
|
my @ok = eval { expand_tags($ok, \%tags) }; |
|
|
4
|
|
|
|
|
9
|
|
|
71
|
4
|
50
|
|
|
|
8
|
nice_die("$@while building the \@EXPORT_OK") if $@; |
|
72
|
4
|
|
|
|
|
10
|
@could_export{@ok} = (); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
14
|
|
|
|
|
16
|
my $ok_only = delete $args{'OK_ONLY'}; |
|
76
|
14
|
100
|
|
|
|
31
|
if ($ok_only) |
|
77
|
|
|
|
|
|
|
{ |
|
78
|
3
|
50
|
|
|
|
7
|
die("OK_ONLY must be a reference to a array") unless ref($ok_only) eq 'ARRAY'; |
|
79
|
|
|
|
|
|
|
|
|
80
|
3
|
|
|
|
|
4
|
@ok_only = eval { expand_tags($ok_only, \%tags) }; |
|
|
3
|
|
|
|
|
5
|
|
|
81
|
3
|
50
|
|
|
|
6
|
nice_die("$@while building the OK_ONLY list") if $@; |
|
82
|
|
|
|
|
|
|
|
|
83
|
3
|
|
|
|
|
7
|
@could_export{@ok_only} = (); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
14
|
100
|
|
|
|
27
|
if (my $fail = delete $args{'FAIL'}) |
|
87
|
|
|
|
|
|
|
{ |
|
88
|
2
|
50
|
|
|
|
5
|
die "FAIL must be a reference to an array" unless ref($fail) eq 'ARRAY'; |
|
89
|
|
|
|
|
|
|
|
|
90
|
2
|
|
|
|
|
4
|
@fail = eval { expand_tags($fail, \%tags) }; |
|
|
2
|
|
|
|
|
6
|
|
|
91
|
2
|
50
|
|
|
|
6
|
nice_die("$@while building \@EXPORT_FAIL") if $@; |
|
92
|
2
|
|
|
|
|
4
|
@could_export{@fail} = (); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
14
|
|
|
|
|
51
|
my @could_export = keys %could_export; |
|
96
|
|
|
|
|
|
|
|
|
97
|
14
|
100
|
|
|
|
36
|
if (defined(my $all = delete $args{'ALL'})) |
|
98
|
|
|
|
|
|
|
{ |
|
99
|
2
|
50
|
|
|
|
7
|
nice_die("No name supplied for ALL") unless length($all); |
|
100
|
|
|
|
|
|
|
|
|
101
|
2
|
50
|
|
|
|
7
|
nice_die("Cannot use '$all' for ALL, already exists") if exists $tags{$all}; |
|
102
|
|
|
|
|
|
|
|
|
103
|
2
|
|
|
|
|
2
|
my %all; |
|
104
|
2
|
|
|
|
|
7
|
@all{@could_export, @will_export} = (); |
|
105
|
|
|
|
|
|
|
|
|
106
|
2
|
|
|
|
|
26
|
$tags{$all} = [keys %all]; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
14
|
100
|
|
|
|
31
|
if ($vars) |
|
110
|
|
|
|
|
|
|
{ |
|
111
|
13
|
100
|
|
|
|
34
|
if (my $ref = ref($vars)) |
|
112
|
|
|
|
|
|
|
{ |
|
113
|
1
|
50
|
|
|
|
4
|
nice_die("VARS was a reference to a ".$ref." instead of an array") |
|
114
|
|
|
|
|
|
|
unless $ref eq 'ARRAY'; |
|
115
|
1
|
|
|
|
|
3
|
@_ = ('vars', grep /^(?:\$|\@|\%)/, eval { expand_tags($vars, \%tags) }); |
|
|
1
|
|
|
|
|
3
|
|
|
116
|
1
|
50
|
|
|
|
5
|
nice_die("$@while building the \@EXPORT") if $@; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
else |
|
119
|
|
|
|
|
|
|
{ |
|
120
|
12
|
|
|
|
|
63
|
@_ = ('vars', grep /^(?:\$|\@|\%)/, @will_export, @could_export); |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
14
|
50
|
|
|
|
32
|
if (%args) |
|
125
|
|
|
|
|
|
|
{ |
|
126
|
0
|
|
|
|
|
0
|
nice_die("Attempt to use unknown keys: ", join(", ", keys %args)); |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
2
|
|
|
2
|
|
12
|
no strict 'refs'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
2435
|
|
|
130
|
14
|
100
|
|
|
|
23
|
if ($isa) |
|
131
|
|
|
|
|
|
|
{ |
|
132
|
13
|
|
|
|
|
13
|
push(@{"$callpkg\::ISA"}, "Exporter"); |
|
|
13
|
|
|
|
|
135
|
|
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
14
|
100
|
|
|
|
29
|
@{"$callpkg\::EXPORT"} = @will_export if @will_export; |
|
|
5
|
|
|
|
|
23
|
|
|
136
|
14
|
100
|
|
|
|
34
|
%{"$callpkg\::EXPORT_TAGS"} = %tags if %tags; |
|
|
8
|
|
|
|
|
52
|
|
|
137
|
14
|
100
|
|
|
|
33
|
@{"$callpkg\::EXPORT_OK"} = $ok_only ? @ok_only : @could_export; |
|
|
14
|
|
|
|
|
68
|
|
|
138
|
14
|
100
|
|
|
|
27
|
@{"$callpkg\::EXPORT_FAIL"} = @fail if @fail; |
|
|
2
|
|
|
|
|
10
|
|
|
139
|
|
|
|
|
|
|
|
|
140
|
14
|
100
|
|
|
|
3200
|
if (@_ > 1) |
|
141
|
|
|
|
|
|
|
{ |
|
142
|
3
|
|
|
|
|
2046
|
goto &vars::import; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub nice_die |
|
147
|
|
|
|
|
|
|
{ |
|
148
|
1
|
|
|
1
|
0
|
2
|
my $msg = shift; |
|
149
|
1
|
|
50
|
|
|
9
|
my $level = shift || 1; |
|
150
|
|
|
|
|
|
|
|
|
151
|
1
|
|
|
|
|
6
|
my ($pkg, $file, $line) = caller(1); |
|
152
|
|
|
|
|
|
|
|
|
153
|
1
|
|
|
|
|
27
|
die "$msg at $file line $line\n"; |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub add_tags($;$) |
|
157
|
|
|
|
|
|
|
{ |
|
158
|
|
|
|
|
|
|
# this takes a reference to tag data and an optional reference to a hash |
|
159
|
|
|
|
|
|
|
# of already exiting tags. If no hash ref is supplied then it creates an |
|
160
|
|
|
|
|
|
|
# empty one |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# It adds the tags from the tag data to the hash ref. |
|
163
|
|
|
|
|
|
|
|
|
164
|
8
|
|
|
8
|
0
|
362
|
my $tag_data = shift; |
|
165
|
8
|
|
100
|
|
|
21
|
my $tags = shift || {}; |
|
166
|
|
|
|
|
|
|
|
|
167
|
8
|
|
|
|
|
25
|
my @tag_data = @$tag_data; |
|
168
|
8
|
|
|
|
|
25
|
while (@tag_data) |
|
169
|
|
|
|
|
|
|
{ |
|
170
|
20
|
|
50
|
|
|
46
|
my $tag_name = shift @tag_data || die "No name for tag"; |
|
171
|
20
|
50
|
|
|
|
49
|
die "Tag name cannot be a reference, maybe you left out a comma" |
|
172
|
|
|
|
|
|
|
if (ref $tag_name); |
|
173
|
|
|
|
|
|
|
|
|
174
|
20
|
50
|
|
|
|
39
|
die "Tried to redefine tag '$tag_name'" |
|
175
|
|
|
|
|
|
|
if (exists $tags->{$tag_name}); |
|
176
|
|
|
|
|
|
|
|
|
177
|
20
|
|
50
|
|
|
40
|
my $tag_list = shift @tag_data || die "No values for tag '$tag_name'"; |
|
178
|
|
|
|
|
|
|
|
|
179
|
20
|
50
|
|
|
|
40
|
die "Tag values for '$tag_name' is not a reference to an array" |
|
180
|
|
|
|
|
|
|
unless ref($tag_list) eq 'ARRAY'; |
|
181
|
|
|
|
|
|
|
|
|
182
|
20
|
|
|
|
|
21
|
my @symbols = eval { expand_tags($tag_list, $tags) }; |
|
|
20
|
|
|
|
|
49
|
|
|
183
|
20
|
50
|
|
|
|
47
|
die "$@while building tag '$tag_name'" if $@; |
|
184
|
|
|
|
|
|
|
|
|
185
|
20
|
|
|
|
|
66
|
$tags->{$tag_name} = \@symbols; |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
|
|
188
|
8
|
|
|
|
|
13
|
return $tags; |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub expand_tags($$) |
|
192
|
|
|
|
|
|
|
{ |
|
193
|
|
|
|
|
|
|
# this takes a list of strings. Each string can be a symbol, or a tag and |
|
194
|
|
|
|
|
|
|
# each may start with a ! to signify deletion. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# We return a list of symbols where all the tag have been expanded and |
|
197
|
|
|
|
|
|
|
# some symbols may have been deleted |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
# we die if we hit an unknown tag |
|
200
|
|
|
|
|
|
|
|
|
201
|
40
|
|
|
40
|
0
|
1691
|
my ($string_list, $so_far) = @_; |
|
202
|
|
|
|
|
|
|
|
|
203
|
40
|
|
|
|
|
173
|
my %this_tag; |
|
204
|
|
|
|
|
|
|
|
|
205
|
40
|
|
|
|
|
192
|
foreach my $sym (@$string_list) |
|
206
|
|
|
|
|
|
|
{ |
|
207
|
117
|
|
|
|
|
109
|
my @symbols; # list of symbols to add or delete |
|
208
|
117
|
|
|
|
|
96
|
my $remove = 0; |
|
209
|
|
|
|
|
|
|
|
|
210
|
117
|
100
|
|
|
|
224
|
if ($sym =~ s/^!//) |
|
211
|
|
|
|
|
|
|
{ |
|
212
|
7
|
|
|
|
|
16
|
$remove = 1; |
|
213
|
|
|
|
|
|
|
} |
|
214
|
|
|
|
|
|
|
|
|
215
|
117
|
100
|
|
|
|
190
|
if ($sym =~ s/^://) |
|
216
|
|
|
|
|
|
|
{ |
|
217
|
14
|
|
|
|
|
20
|
my $sub_tag = $so_far->{$sym}; |
|
218
|
14
|
100
|
|
|
|
37
|
die "Tried to use an unknown tag '$sym'" unless defined($sub_tag); |
|
219
|
|
|
|
|
|
|
|
|
220
|
13
|
100
|
|
|
|
20
|
if ($remove) |
|
221
|
|
|
|
|
|
|
{ |
|
222
|
5
|
|
|
|
|
15
|
delete @this_tag{@$sub_tag} |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
else |
|
225
|
|
|
|
|
|
|
{ |
|
226
|
8
|
|
|
|
|
29
|
@this_tag{@$sub_tag} = (); |
|
227
|
|
|
|
|
|
|
} |
|
228
|
|
|
|
|
|
|
} |
|
229
|
|
|
|
|
|
|
else |
|
230
|
|
|
|
|
|
|
{ |
|
231
|
103
|
100
|
|
|
|
123
|
if ($remove) |
|
232
|
|
|
|
|
|
|
{ |
|
233
|
2
|
|
|
|
|
6
|
delete $this_tag{$sym}; |
|
234
|
|
|
|
|
|
|
} |
|
235
|
|
|
|
|
|
|
else |
|
236
|
|
|
|
|
|
|
{ |
|
237
|
101
|
|
|
|
|
213
|
$this_tag{$sym} = undef; |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
} |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
|
|
242
|
39
|
|
|
|
|
237
|
return keys %this_tag; |
|
243
|
|
|
|
|
|
|
} |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
1; |
|
246
|
|
|
|
|
|
|
__END__ |