| 1 | package Exporter::Tidy; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # use strict; | ||||||||||||||||||||||||||||
| 4 | # no strict 'refs'; | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # our | ||||||||||||||||||||||||||||
| 7 | 1 | $VERSION = '0.08'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | sub import { | ||||||||||||||||||||||||||||
| 10 | 5 | ▶ | my (undef, %tags) = @_; | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 11 | 5 | my $caller = caller; | |||||||||||||||||||||||||||
| 12 | 5 | my $map = delete($tags{_map}); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 5 | my %available; | |||||||||||||||||||||||||||
| 15 | 5 | ▶ | @available{ grep !ref, keys %$map } = () if $map; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | 5 | @available{ grep !/^:/, map @$_, values %tags } = (); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 5 | ▶ | $tags{all} ||= [ keys %available ]; | ||||||||||||||||||||||||||
|
Condition50%1/2
$tags{"all"} ||= [keys %available]
MC/DC0%0/1
$tags{"all"} ||= [keys %available]
$tags{"all"}
Truth table50%1/2
A
A= $tags{"all"}
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 5 | *{"$caller\::import"} = sub { | |||||||||||||||||||||||||||
| 21 | 4 | ▶ | my ($me, @symbols) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=17 SCAR=28.5
| |||||||||||||||||||||||||||||
| 22 | 4 | my $caller = caller; | |||||||||||||||||||||||||||
| 23 | 4 | ▶ | @symbols = @{ $tags{default} } if @symbols == 0 and exists $tags{default}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@symbols == 0 and exists $tags{"default"}
MC/DC50%1/2
@symbols == 0 and exists $tags{"default"}
@symbols == 0
exists $tags{"default"}
Truth table66%2/3
A and B
A= @symbols == 0B= exists $tags{"default"}
| |||||||||||||||||||||||||||||
| 24 | 4 | my %exported; | |||||||||||||||||||||||||||
| 25 | 4 | my $prefix = ''; | |||||||||||||||||||||||||||
| 26 | 4 | ▶ | while (my $symbol = shift @symbols) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 23 | ▶ | $symbol eq '_prefix' and ($prefix = shift @symbols, next); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 21 | ▶ | my $real = $map && exists $map->{$symbol} ? $map->{$symbol} : $symbol; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$map and exists $map->{$symbol}
MC/DC50%1/2
$map and exists $map->{$symbol}
$map
exists $map->{$symbol}
Truth table66%2/3
A and B
A= $mapB= exists $map->{$symbol}
| |||||||||||||||||||||||||||||
| 29 | 21 | ▶ | next if exists $exported{"$prefix$real"}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 21 | undef $exported{"$prefix$symbol"}; | |||||||||||||||||||||||||||
| 31 | 21 | $i++; | |||||||||||||||||||||||||||
| 32 | $real =~ /^:(.*)/ and ( | ||||||||||||||||||||||||||||
| 33 | (exists $tags{$1} or | ||||||||||||||||||||||||||||
| 34 | (require Carp, Carp::croak("Unknown tag: $1"))), | ||||||||||||||||||||||||||||
| 35 | 21 | ▶ | push(@symbols, @{ $tags{$1} }), | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
exists $tags{$1} or require Carp, Carp::croak("Unknown tag: $1")
MC/DC0%0/2
exists $tags{$1} or require Carp, Carp::croak("Unknown tag: $1")
exists $tags{$1}
require Carp, Carp::croak("Unknown tag: $1")
Truth table33%1/3
A or B
A= exists $tags{$1}B= require Carp, Carp::croak("Unknown tag: $1")
| |||||||||||||||||||||||||||||
| 36 | next | ||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||
| 38 | ref $real and ( | ||||||||||||||||||||||||||||
| 39 | $symbol =~ s/^[\@\$%*]//, | ||||||||||||||||||||||||||||
| 40 | 20 | ▶ | *{"$caller\::$prefix$symbol"} = $real, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | next | ||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | 15 | ▶ | exists $available{$symbol} or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | (require Carp, Carp::croak("Unknown symbol: $real")); | ||||||||||||||||||||||||||||
| 45 | 15 | my ($sigil, $name) = $real =~ /^([\@\$%*]?)(.*)/; | |||||||||||||||||||||||||||
| 46 | 15 | $symbol =~ s/^[\@\$%*]//; | |||||||||||||||||||||||||||
| 47 | 15 | *{"$caller\::$prefix$symbol"} = | |||||||||||||||||||||||||||
| 48 | 3 | ▶ | $sigil eq '' ? \&{"$me\::$name"} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 3 | ▶ | : $sigil eq '$' ? \${"$me\::$name"} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 3 | ▶ | : $sigil eq '@' ? \@{"$me\::$name"} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 3 | ▶ | : $sigil eq '%' ? \%{"$me\::$name"} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 15 | ▶ | : $sigil eq '*' ? \*{"$me\::$name"} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | : (require Carp, Carp::croak("Strange symbol: $real")); | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | 5 | }; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 1 | 1; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||||||||||||