line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Import::Export; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
381753
|
use Carp; |
|
6
|
|
|
|
|
49
|
|
|
6
|
|
|
|
|
308
|
|
4
|
6
|
|
|
6
|
|
2793
|
use namespace::clean (); |
|
6
|
|
|
|
|
86273
|
|
|
6
|
|
|
|
|
3729
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
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
|
19
|
|
|
19
|
|
5314
|
my ($pkg, $options, $caller) = (shift, {}, caller()); |
20
|
19
|
100
|
|
|
|
190
|
return unless my @export = @_; |
21
|
|
|
|
|
|
|
Carp::croak('define your %EX export hash') |
22
|
13
|
100
|
|
|
|
20
|
unless (%EX) = %{"${pkg}::EX"}; |
|
13
|
|
|
|
|
216
|
|
23
|
|
|
|
|
|
|
|
24
|
12
|
100
|
|
|
|
34
|
$options = pop @export if ref $export[-1]; |
25
|
12
|
100
|
|
|
|
26
|
$caller = $options->{-caller} if exists $options->{-caller}; |
26
|
12
|
|
|
|
|
40
|
my @exported = export($pkg, $caller, @export); |
27
|
|
|
|
|
|
|
|
28
|
10
|
100
|
|
|
|
2643
|
$options->{clean} and "$options->{clean}" eq "import" |
|
|
100
|
|
|
|
|
|
29
|
|
|
|
|
|
|
? namespace::clean->clean_subroutines( # sub import { p->import(@export, { clean => 'import' }) } |
30
|
|
|
|
|
|
|
$caller, |
31
|
|
|
|
|
|
|
@exported |
32
|
|
|
|
|
|
|
) |
33
|
|
|
|
|
|
|
: namespace::clean->import( # use p @export, { clean => 1 } |
34
|
|
|
|
|
|
|
-cleanee => $caller, |
35
|
|
|
|
|
|
|
@exported |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub export { |
40
|
17
|
|
|
17
|
1
|
28
|
my ($pkg, $caller, @exported) = (shift, shift); |
41
|
17
|
|
|
|
|
45
|
while (my $ex = shift) { |
42
|
20
|
|
|
|
|
26
|
my $type; |
43
|
20
|
100
|
|
|
|
44
|
if ( ! $EX{$ex} ) { |
44
|
|
|
|
|
|
|
my @export = grep { |
45
|
6
|
|
|
|
|
15
|
grep { $_ =~ m{\Q$ex\E} } @{ $EX{$_} } |
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
59
|
|
|
9
|
|
|
|
|
15
|
|
46
|
|
|
|
|
|
|
} keys %EX; |
47
|
|
|
|
|
|
|
scalar @export |
48
|
6
|
100
|
|
|
|
103
|
? return export($pkg, $caller, (@export, @_)) |
49
|
|
|
|
|
|
|
: Carp::croak "$ex is not exported"; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
14
|
100
|
|
|
|
62
|
$type = ($ex =~ s/^(\W)//) ? $1 : "&"; |
53
|
14
|
100
|
|
|
|
284
|
$caller->can($ex) and next; |
54
|
|
|
|
|
|
|
|
55
|
13
|
100
|
|
|
|
119
|
my $exporting = $EXTYPE{$type} or Carp::croak("Cant export symbol $type"); |
56
|
12
|
|
|
|
|
24
|
*{"${caller}::${ex}"} = $exporting->($pkg, $ex); |
|
12
|
|
|
|
|
32
|
|
57
|
12
|
|
|
|
|
39
|
push @exported, $ex; |
58
|
|
|
|
|
|
|
} |
59
|
10
|
|
|
|
|
31
|
return @exported; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
7
|
|
|
7
|
|
7
|
sub _export_code { \&{"$_[0]::$_[1]"} } |
|
7
|
|
|
|
|
24
|
|
63
|
2
|
|
|
2
|
|
3
|
sub _export_scalar { \${"$_[0]::$_[1]"} } |
|
2
|
|
|
|
|
8
|
|
64
|
1
|
|
|
1
|
|
2
|
sub _export_array { \@{"$_[0]::$_[1]"} } |
|
1
|
|
|
|
|
2
|
|
65
|
1
|
|
|
1
|
|
2
|
sub _export_hash { \%{"$_[0]::$_[1]"} } |
|
1
|
|
|
|
|
3
|
|
66
|
1
|
|
|
1
|
|
1
|
sub _export_glob { *{"$_[0]::$_[1]"} } |
|
1
|
|
|
|
|
4
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |