| 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | package Importer::Zim::Base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | $Importer::Zim::Base::VERSION = '0.12.0'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: Base module for Importer::Zim backends | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use Module::Runtime (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use Importer::Zim::Utils qw(DEBUG carp croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | sub import_into { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import_into: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | carp "$class->import(@_)" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my @exports = _prepare_args( $class, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | if ( $class eq 'Importer::Zim::Lexical' ) { # +Lexical backend | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # require Sub::Inject; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | @_ = map { @{$_}{qw(export code)} } @exports; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | goto &Sub::Inject::sub_inject; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | return $class->can('_export_to')->( # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | map { ; "${caller}::$_->{export}" => $_->{code} } @exports | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ## Non-optimized code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | #my $caller = caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | #@_ = $caller, map { @{$_}{qw(export code)} } @exports; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | #goto &{ $class->can('export_to') }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | sub _prepare_args { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 16 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare_args: called CC=18 SCAR=29.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 16 | ▶ | my $package = shift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | or croak qq{Usage: use $class MODULE => [\%OPTS =>] EXPORTS...\n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 16 | ▶ | my $opts = _module_opts( ref $_[0] eq 'HASH' ? shift : {} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 16 | ▶ | my @version = exists $opts->{-version} ? ( $opts->{-version} ) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 16 | &Module::Runtime::use_module( $package, @version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 16 | my $can_export = _can_export($package); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 16 | my ( @exports, %seen ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 16 | ▶ | @_ = @{"${package}::EXPORT"} unless @_ || !${"${package}::"}{'EXPORT'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ or not do {
"${package}::"
}->{"EXPORT"}
MC/DC50%1/2
@_ or not do {
"${package}::"
}->{"EXPORT"}
@_
not do {
"${package}::"
}->{"EXPORT"}
Truth table66%2/3
A or not(B)
A= @_B= not do {
"${package}::"
}->{"EXPORT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 16 | ▶ | while (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 166 | my @symbols = _expand_symbol( $package, shift ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 166 | ▶ | my $opts = _import_opts( ref $_[0] eq 'HASH' ? shift : {}, $opts ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | exists $opts->{-filter} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 166 | ▶ | and @symbols = grep &{ $opts->{-filter} }, @symbols; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 166 | for my $symbol (@symbols) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | croak qq{"$symbol" is not exported by "$package"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 89 | ▶ | if $opts->{-strict} && !$can_export->{$symbol}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opts->{"-strict"} and not $can_export->{$symbol}
MC/DC0%0/2
$opts->{"-strict"} and not $can_export->{$symbol}
$opts->{"-strict"}
not $can_export->{$symbol}
Truth table66%2/3
A and not(B)
A= $opts->{"-strict"}B= not $can_export->{$symbol}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 89 | ▶ | croak qq{Can't handle "$symbol"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | if $symbol =~ /^[\$\@\%\*]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 89 | my $sub = *{"${package}::${symbol}"}{CODE}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 89 | my $export = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 89 | ▶ | local $_ = $opts->{-as} // $symbol; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opts->{"-as"} // $symbol
MC/DC0%0/2
$opts->{"-as"} // $symbol
$opts->{"-as"}
$symbol
Truth table66%2/3
A // B
A= $opts->{"-as"}B= $symbol
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 89 | ▶ | exists $opts->{-map} ? $opts->{-map}->() : $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 89 | ▶ | croak qq{Can't find "$symbol" in "$package"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | unless $sub; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 89 | my $seen = $seen{$export}{$sub}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | croak qq{Can't import as "$export" twice} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 89 | ▶ | if keys %{ $seen{$export} } > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 89 | ▶ | unless ($seen) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 87 | warn(qq{ Importing "${package}::${symbol}" as "$export"\n}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | if DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 87 | push @exports, { export => $export, code => $sub }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 16 | return @exports; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | sub _module_opts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | state $IS_MODULE_OPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 16 | ▶ | = { map { ; "-$_" => 1 } qw(how filter map prefix strict version) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_module_opts: called CC=7 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 16 | my %opts = ( -strict => !!1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 16 | my $o = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 16 | ▶ | $opts{-strict} = !!$o->{-strict} if exists $o->{-strict}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 16 | ▶ | exists $o->{-filter} and $opts{-filter} = $o->{-filter}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | exists $o->{-map} and $opts{-map} = $o->{-map} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 16 | ▶ | or exists $o->{-prefix} and $opts{-map} = sub { $o->{-prefix} . $_ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.9
Branch: 1 branch
Condition44%4/9
exists $o->{'-map'} && ($opts{'-map'} = $o->{'-map'}) || exists $o->{'-prefix'} && ($opts{'-map'} = sub {
$o->{'-prefix'} . $_;
}
)
exists $o->{"-map"} and $opts{"-map"} = $o->{"-map"}
exists $o->{"-prefix"} and $opts{"-map"} = sub {
$o->{"-prefix"} . $_;
}
MC/DC0%0/4
exists $o->{'-map'} && ($opts{'-map'} = $o->{'-map'}) || exists $o->{'-prefix'} && ($opts{'-map'} = sub {
$o->{'-prefix'} . $_;
}
)
exists $o->{"-map"}
$opts{"-map"} = $o->{"-map"}
exists $o->{"-prefix"}
$opts{"-map"} = sub {
$o->{"-prefix"} . $_;
}
Truth table0%0/7
A and B || C and D
A= exists $o->{"-map"}B= $opts{"-map"} = $o->{"-map"}C= exists $o->{"-prefix"}D= $opts{"-map"} = sub {
$o->{"-prefix"} . $_;
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 16 | ▶ | if ( my @bad = grep { !$IS_MODULE_OPTION->{$_} } keys %$o ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | carp qq{Ignoring unknown module options (@bad)\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 16 | return \%opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # $opts = _import_opts($opts1, $m_opts); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | sub _import_opts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | state $IS_IMPORT_OPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 166 | ▶ | = { map { ; "-$_" => 1 } qw(as filter map prefix strict) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_import_opts: called CC=11 SCAR=25.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 166 | my %opts = ( -strict => !!1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | exists $_[1]{-filter} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 166 | ▶ | and $opts{-filter} = _expand_filter( $_[1]{-filter} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 166 | ▶ | exists $_[1]{-map} and $opts{-map} = $_[1]{-map}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 166 | ▶ | exists $_[1]{-strict} and $opts{-strict} = $_[1]{-strict}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 166 | my $o = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 166 | ▶ | $opts{-as} = $o->{-as} if exists $o->{-as}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 166 | ▶ | exists $o->{-filter} and $opts{-filter} = _expand_filter( $o->{-filter} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | exists $o->{-map} and $opts{-map} = $o->{-map} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 166 | ▶ | or exists $o->{-prefix} and $opts{-map} = sub { $o->{-prefix} . $_ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.9
Branch: 1 branch
Condition44%4/9
exists $o->{'-map'} && ($opts{'-map'} = $o->{'-map'}) || exists $o->{'-prefix'} && ($opts{'-map'} = sub {
$o->{'-prefix'} . $_;
}
)
exists $o->{"-map"} and $opts{"-map"} = $o->{"-map"}
exists $o->{"-prefix"} and $opts{"-map"} = sub {
$o->{"-prefix"} . $_;
}
MC/DC0%0/4
exists $o->{'-map'} && ($opts{'-map'} = $o->{'-map'}) || exists $o->{'-prefix'} && ($opts{'-map'} = sub {
$o->{'-prefix'} . $_;
}
)
exists $o->{"-map"}
$opts{"-map"} = $o->{"-map"}
exists $o->{"-prefix"}
$opts{"-map"} = sub {
$o->{"-prefix"} . $_;
}
Truth table0%0/7
A and B || C and D
A= exists $o->{"-map"}B= $opts{"-map"} = $o->{"-map"}C= exists $o->{"-prefix"}D= $opts{"-map"} = sub {
$o->{"-prefix"} . $_;
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 166 | ▶ | $opts{-strict} = !!$o->{-strict} if exists $o->{-strict}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 166 | ▶ | if ( my @bad = grep { !$IS_IMPORT_OPTION->{$_} } keys %$o ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | carp qq{Ignoring unknown symbol options (@bad)\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 166 | return \%opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | sub _expand_filter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 144 | ▶ | my $filter = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_filter: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 144 | ▶ | ref $filter eq 'Regexp' ? sub {/$filter/} : $filter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | sub _expand_symbol { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 166 | ▶ | return $_[1] unless ref $_[1] || $_[1] =~ /^[:&]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_symbol: called CC=9 SCAR=25.1
Branch: 1 branch
Condition66%2/3
ref $_[1] or $_[1] =~ /^[:&]/
MC/DC50%1/2
ref $_[1] or $_[1] =~ /^[:&]/
ref $_[1]
$_[1] =~ /^[:&]/
Truth table66%2/3
A or B
A= ref $_[1]B= $_[1] =~ /^[:&]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 5 | ▶ | return map { /^&/ ? substr( $_, 1 ) : $_ } @{ $_[1] } if ref $_[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 5 | ▶ | return substr( $_[1], 1 ) if $_[1] =~ /^&/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 3 | my ( $package, $tag ) = ( $_[0], substr( $_[1], 1 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | my $symbols | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 3 | ▶ | = ${"${package}::"}{'EXPORT_TAGS'} && ${"${package}::EXPORT_TAGS"}{$tag} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
do {
"${package}::"
}->{'EXPORT_TAGS'} && do {
"${package}::EXPORT_TAGS"
}->{$tag}
MC/DC0%0/2
do {
"${package}::"
}->{'EXPORT_TAGS'} && do {
"${package}::EXPORT_TAGS"
}->{$tag}
do {
"${package}::"
}->{'EXPORT_TAGS'}
do {
"${package}::EXPORT_TAGS"
}->{$tag}
Truth table33%1/3
A && B
A= do {
"${package}::"
}->{'EXPORT_TAGS'}B= do {
"${package}::EXPORT_TAGS"
}->{$tag}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | or return $_[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 3 | ▶ | return map { /^&/ ? substr( $_, 1 ) : $_ } @$symbols; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | sub _can_export { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 16 | ▶ | my $package = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_can_export: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 16 | my %exports; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 16 | ▶ | for ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 16 | ▶ | ( ${"${package}::"}{'EXPORT'} ? @{"${package}::EXPORT"} : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 16 | ( ${"${package}::"}{'EXPORT_OK'} ? @{"${package}::EXPORT_OK"} : () ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 374 | ▶ | my $x = /^&/ ? substr( $_, 1 ) : $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 374 | $exports{$x}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 16 | return \%exports; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 5 | ▶ | no Importer::Zim::Utils qw(DEBUG carp croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | #pod =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | #pod =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | #pod "The Earth is safe once more, GIR! Now let's go destroy it!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | #pod – Zim | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | #pod No public interface. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | #pod =head1 DEBUGGING | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | #pod You can set the C<IMPORTER_ZIM_DEBUG> environment variable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | #pod for get some diagnostics information printed to C<STDERR>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | #pod IMPORTER_ZIM_DEBUG=1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | #pod =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | #pod L<Importer::Zim> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||