line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Exporter::Tidy; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# use strict; |
4
|
|
|
|
|
|
|
# no strict 'refs'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# our |
7
|
|
|
|
|
|
|
$VERSION = '0.07'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub import { |
10
|
5
|
|
|
5
|
|
525
|
my (undef, %tags) = @_; |
11
|
5
|
|
|
|
|
13
|
my $caller = caller; |
12
|
5
|
|
|
|
|
11
|
my $map = delete($tags{_map}); |
13
|
|
|
|
|
|
|
|
14
|
5
|
|
|
|
|
7
|
my %available; |
15
|
5
|
100
|
|
|
|
18
|
@available{ grep !ref, keys %$map } = () if $map; |
16
|
5
|
|
|
|
|
45
|
@available{ grep !/^:/, map @$_, values %tags } = (); |
17
|
|
|
|
|
|
|
|
18
|
5
|
|
50
|
|
|
41
|
$tags{all} ||= [ keys %available ]; |
19
|
|
|
|
|
|
|
|
20
|
5
|
|
|
|
|
435
|
*{"$caller\::import"} = sub { |
21
|
4
|
|
|
4
|
|
217
|
my ($me, @symbols) = @_; |
22
|
4
|
|
|
|
|
8
|
my $caller = caller; |
23
|
4
|
100
|
66
|
|
|
17
|
@symbols = @{ $tags{default} } if @symbols == 0 and exists $tags{default}; |
|
1
|
|
|
|
|
3
|
|
24
|
4
|
|
|
|
|
6
|
my %exported; |
25
|
4
|
|
|
|
|
6
|
my $prefix = ''; |
26
|
4
|
|
|
|
|
13
|
while (my $symbol = shift @symbols) { |
27
|
23
|
100
|
|
|
|
47
|
$symbol eq '_prefix' and ($prefix = shift @symbols, next); |
28
|
21
|
100
|
66
|
|
|
69
|
my $real = $map && exists $map->{$symbol} ? $map->{$symbol} : $symbol; |
29
|
21
|
50
|
|
|
|
52
|
next if exists $exported{"$prefix$real"}; |
30
|
21
|
|
|
|
|
39
|
undef $exported{"$prefix$symbol"}; |
31
|
21
|
|
|
|
|
23
|
$i++; |
32
|
1
|
|
|
|
|
6
|
$real =~ /^:(.*)/ and ( |
33
|
|
|
|
|
|
|
(exists $tags{$1} or |
34
|
|
|
|
|
|
|
(require Carp, Carp::croak("Unknown tag: $1"))), |
35
|
21
|
100
|
50
|
|
|
58
|
push(@symbols, @{ $tags{$1} }), |
36
|
|
|
|
|
|
|
next |
37
|
|
|
|
|
|
|
); |
38
|
5
|
|
|
|
|
163
|
ref $real and ( |
39
|
|
|
|
|
|
|
$symbol =~ s/^[\@\$%*]//, |
40
|
20
|
100
|
|
|
|
56
|
*{"$caller\::$prefix$symbol"} = $real, |
41
|
|
|
|
|
|
|
next |
42
|
|
|
|
|
|
|
); |
43
|
15
|
50
|
|
|
|
33
|
exists $available{$symbol} or |
44
|
|
|
|
|
|
|
(require Carp, Carp::croak("Unknown symbol: $real")); |
45
|
15
|
|
|
|
|
63
|
my ($sigil, $name) = $real =~ /^([\@\$%*]?)(.*)/; |
46
|
15
|
|
|
|
|
38
|
$symbol =~ s/^[\@\$%*]//; |
47
|
15
|
|
|
|
|
2339
|
*{"$caller\::$prefix$symbol"} = |
|
3
|
|
|
|
|
8
|
|
48
|
3
|
|
|
|
|
8
|
$sigil eq '' ? \&{"$me\::$name"} |
49
|
3
|
|
|
|
|
10
|
: $sigil eq '$' ? \${"$me\::$name"} |
50
|
3
|
|
|
|
|
9
|
: $sigil eq '@' ? \@{"$me\::$name"} |
51
|
3
|
|
|
|
|
8
|
: $sigil eq '%' ? \%{"$me\::$name"} |
52
|
15
|
50
|
|
|
|
55
|
: $sigil eq '*' ? \*{"$me\::$name"} |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
53
|
|
|
|
|
|
|
: (require Carp, Carp::croak("Strange symbol: $real")); |
54
|
|
|
|
|
|
|
} |
55
|
5
|
|
|
|
|
37
|
}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |