line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Import::Export; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
315925
|
use Carp; |
|
6
|
|
|
|
|
52
|
|
|
6
|
|
|
|
|
297
|
|
4
|
6
|
|
|
6
|
|
2212
|
use namespace::clean (); |
|
6
|
|
|
|
|
72507
|
|
|
6
|
|
|
|
|
2900
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our %EX; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our %EXTYPE = ( |
11
|
|
|
|
|
|
|
'&' => \&_export_code, |
12
|
|
|
|
|
|
|
'$' => \&_export_scalar, |
13
|
|
|
|
|
|
|
'@' => \&_export_array, |
14
|
|
|
|
|
|
|
'%' => \&_export_hash, |
15
|
|
|
|
|
|
|
'*' => \&_export_glob, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub import { |
19
|
18
|
|
|
18
|
|
4637
|
my ($pkg) = shift; |
20
|
18
|
100
|
|
|
|
156
|
return unless my @export = @_; |
21
|
12
|
100
|
|
|
|
37
|
my $options = pop @export if ref $export[-1]; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Carp::croak('define your %EX export hash') |
24
|
12
|
100
|
|
|
|
18
|
unless (%EX) = %{"${pkg}::EX"}; |
|
12
|
|
|
|
|
225
|
|
25
|
|
|
|
|
|
|
|
26
|
11
|
|
|
|
|
22
|
my $caller = caller(); |
27
|
11
|
|
|
|
|
24
|
my @exported = export($pkg, $caller, @export); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
'namespace::clean'->import( |
30
|
|
|
|
|
|
|
-cleanee => $caller, |
31
|
|
|
|
|
|
|
@exported, |
32
|
9
|
100
|
|
|
|
2923
|
) if $options->{clean}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub export { |
36
|
17
|
|
|
17
|
1
|
26
|
my ($pkg, $caller, @exported) = (shift, shift); |
37
|
17
|
|
|
|
|
33
|
while (my $ex = shift) { |
38
|
20
|
|
|
|
|
20
|
my $type; |
39
|
20
|
100
|
|
|
|
37
|
if ( ! $EX{$ex} ) { |
40
|
|
|
|
|
|
|
my @export = grep { |
41
|
7
|
|
|
|
|
18
|
grep { $_ =~ m{\Q$ex\E} } @{ $EX{$_} } |
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
65
|
|
|
10
|
|
|
|
|
15
|
|
42
|
|
|
|
|
|
|
} keys %EX; |
43
|
|
|
|
|
|
|
scalar @export |
44
|
7
|
100
|
|
|
|
121
|
? return export($pkg, $caller, (@export, @_)) |
45
|
|
|
|
|
|
|
: Carp::croak "$ex is not exported"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
13
|
100
|
|
|
|
48
|
$type = ($ex =~ s/^(\W)//) ? $1 : "&"; |
49
|
13
|
100
|
|
|
|
145
|
$caller->can($ex) and next; |
50
|
|
|
|
|
|
|
|
51
|
12
|
100
|
|
|
|
102
|
my $exporting = $EXTYPE{$type} or Carp::croak("Cant export symbol $type"); |
52
|
11
|
|
|
|
|
19
|
*{"${caller}::${ex}"} = $exporting->($pkg, $ex); |
|
11
|
|
|
|
|
29
|
|
53
|
11
|
|
|
|
|
29
|
push @exported, $ex; |
54
|
|
|
|
|
|
|
} |
55
|
9
|
|
|
|
|
22
|
return @expoted; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
6
|
|
|
6
|
|
9
|
sub _export_code { \&{"$_[0]::$_[1]"} } |
|
6
|
|
|
|
|
18
|
|
59
|
2
|
|
|
2
|
|
3
|
sub _export_scalar { \${"$_[0]::$_[1]"} } |
|
2
|
|
|
|
|
7
|
|
60
|
1
|
|
|
1
|
|
1
|
sub _export_array { \@{"$_[0]::$_[1]"} } |
|
1
|
|
|
|
|
4
|
|
61
|
1
|
|
|
1
|
|
2
|
sub _export_hash { \%{"$_[0]::$_[1]"} } |
|
1
|
|
|
|
|
2
|
|
62
|
1
|
|
|
1
|
|
2
|
sub _export_glob { *{"$_[0]::$_[1]"} } |
|
1
|
|
|
|
|
4
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |