| 1 | package Exporter::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 17 | ▶ | use 5.006001; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 17 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 17 | ▶ | use warnings; no warnings qw(void once uninitialized numeric redefine); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 17 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||||||
| 8 | 17 | our $VERSION = '1.005_000'; | |||||||||||||||||||||||||||||||||||||||||||||
| 9 | 17 | our @EXPORT_OK = qw< mkopt mkopt_hash _croak _carp >; | |||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | *_HAS_NATIVE_LEXICAL_SUB = ( $] ge '5.037002' ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | ? sub () { !!1 } | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 17 | ▶ | : sub () { !!0 }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=4 SCAR=16.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | *_HAS_MODULE_LEXICAL_SUB = ( $] ge '5.011002' and eval('require Lexical::Sub') ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | ? sub () { !!1 } | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 17 | ▶ | : sub () { !!0 }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$] ge "5.011002" and eval "require Lexical::Sub"
MC/DC0%0/2
$] ge "5.011002" and eval "require Lexical::Sub"
$] ge "5.011002"
eval "require Lexical::Sub"
Truth table33%1/3
A and B
A= $] ge "5.011002"B= eval "require Lexical::Sub"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 7 | ▶ | sub _croak ($;@) { require Carp; my $fmt = shift; @_ = sprintf($fmt, @_); goto \&Carp::croak } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_croak: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | sub _carp ($;@) { require Carp; my $fmt = shift; @_ = sprintf($fmt, @_); goto \&Carp::carp } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_carp: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | my $_process_optlist = sub | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 47 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 47 | my ($global_opts, $opts, $want, $not_want) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 47 | ▶ | while (@$opts) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 110 | my $opt = shift @{$opts}; | |||||||||||||||||||||||||||||||||||||||||||||
| 31 | 110 | my ($name, $value) = @$opt; | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ($name =~ m{\A\!(/.+/[msixpodual]*)\z}) ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | do { | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | my @not = $class->_exporter_expand_regexp("$1", $value, $global_opts); | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | ++$not_want->{$_->[0]} for @not; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } : | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ($name =~ m{\A\\z}) ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | do { | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | my @not = $class->_exporter_expand_tag("$1", $value, $global_opts); | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | ++$not_want->{$_->[0]} for @not; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } : | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ($name =~ m{\A\!(.+)\z}) ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 110 | ▶ | (++$not_want->{$1}) : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ($name =~ m{\A[:-](.+)\z}) ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | push(@$opts, $class->_exporter_expand_tag("$1", $value, $global_opts)) : | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ($name =~ m{\A/.+/[msixpodual]*\z}) ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | push(@$opts, $class->_exporter_expand_regexp($name, $value, $global_opts)) : | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # else ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | push(@$want, $opt); | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | sub import | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 43 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=12 SCAR=25.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 43 | ▶ | my $global_opts = +{ @_ && ref($_[0]) eq q(HASH) ? %{+shift} : () }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ and ref $_[0] eq "HASH"
MC/DC100%2/2
@_ and ref $_[0] eq "HASH"
@_
ref $_[0] eq "HASH"
Truth table100%3/3
A and B
A= @_B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 43 | ▶ | if ( defined $global_opts->{into} and $global_opts->{into} eq '-lexical' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $global_opts->{"into"} and $global_opts->{"into"} eq "-lexical"
MC/DC0%0/2
defined $global_opts->{"into"} and $global_opts->{"into"} eq "-lexical"
defined $global_opts->{"into"}
$global_opts->{"into"} eq "-lexical"
Truth table66%2/3
A and B
A= defined $global_opts->{"into"}B= $global_opts->{"into"} eq "-lexical"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $global_opts->{lexical} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | delete $global_opts->{into}; | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 43 | ▶ | if ( not defined $global_opts->{into} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 32 | $global_opts->{into} = caller; | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 43 | my @want; | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | 43 | my %not_want; $global_opts->{not} = \%not_want; | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | 17 | ▶ | my @args = do { no strict qw(refs); @_ ? @_ : @{"$class\::EXPORT"} }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 43 | my $opts = mkopt(\@args); | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | 43 | $class->$_process_optlist($global_opts, $opts, \@want, \%not_want); | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | $global_opts->{installer} ||= $class->_exporter_lexical_installer( $global_opts ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 43 | ▶ | if $global_opts->{lexical}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$global_opts->{"installer"} ||= $class->_exporter_lexical_installer($global_opts)
MC/DC0%0/2
$global_opts->{"installer"} ||= $class->_exporter_lexical_installer($global_opts)
$global_opts->{"installer"}
$class->_exporter_lexical_installer($global_opts)
Truth table33%1/3
A ||= B
A= $global_opts->{"installer"}B= $class->_exporter_lexical_installer($global_opts)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 43 | my $permitted = $class->_exporter_permitted_regexp($global_opts); | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | 43 | $class->_exporter_validate_opts($global_opts); | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 43 | for my $wanted (@want) { | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | 74 | ▶ | next if $not_want{$wanted->[0]}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 67 | my %symbols = $class->_exporter_expand_sub(@$wanted, $global_opts, $permitted); | |||||||||||||||||||||||||||||||||||||||||||||
| 83 | $class->_exporter_install_sub($_, $wanted->[1], $global_opts, $symbols{$_}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 64 | for keys %symbols; | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | sub unimport | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 4 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unimport: called CC=15 SCAR=30.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 4 | ▶ | my $global_opts = +{ @_ && ref($_[0]) eq q(HASH) ? %{+shift} : () }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ and ref $_[0] eq "HASH"
@_
ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= @_B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 4 | $global_opts->{is_unimport} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 4 | ▶ | if ( defined $global_opts->{into} and $global_opts->{into} eq '-lexical' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $global_opts->{"into"} and $global_opts->{"into"} eq "-lexical"
MC/DC0%0/2
defined $global_opts->{"into"} and $global_opts->{"into"} eq "-lexical"
defined $global_opts->{"into"}
$global_opts->{"into"} eq "-lexical"
Truth table33%1/3
A and B
A= defined $global_opts->{"into"}B= $global_opts->{"into"} eq "-lexical"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $global_opts->{lexical} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | delete $global_opts->{into}; | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 4 | ▶ | if ( not defined $global_opts->{into} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 4 | $global_opts->{into} = caller; | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 4 | my @want; | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | 4 | my %not_want; $global_opts->{not} = \%not_want; | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | 4 | ▶ | my @args = do { our %TRACKED; @_ ? @_ : keys(%{$TRACKED{$class}{$global_opts->{into}}}) }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 4 | my $opts = mkopt(\@args); | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | 4 | $class->$_process_optlist($global_opts, $opts, \@want, \%not_want); | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | my $permitted = $class->_exporter_permitted_regexp($global_opts); | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | 4 | $class->_exporter_validate_unimport_opts($global_opts); | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 4 | my $expando = $class->can('_exporter_expand_sub'); | |||||||||||||||||||||||||||||||||||||||||||||
| 112 | 4 | ▶ | $expando = undef if $expando == \&_exporter_expand_sub; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 4 | for my $wanted (@want) | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 4 | ▶ | next if $not_want{$wanted->[0]}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 4 | ▶ | if ($wanted->[1]) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | _carp("Passing options to unimport '%s' makes no sense", $wanted->[0]) | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | ▶ | unless (ref($wanted->[1]) eq 'HASH' and not keys %{$wanted->[1]}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $wanted->[1] eq "HASH" and not keys %{$$wanted[1];}
MC/DC0%0/2
ref $wanted->[1] eq "HASH" and not keys %{$$wanted[1];}
ref $wanted->[1] eq "HASH"
not keys %{$$wanted[1];}
Truth table33%1/3
A and not(B)
A= ref $wanted->[1] eq "HASH"B= not keys %{$$wanted[1];}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | my %symbols = defined($expando) | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | ? $class->$expando(@$wanted, $global_opts, $permitted) | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 4 | ▶ | : ($wanted->[0] => sub { "dummy" }); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | $class->_exporter_uninstall_sub($_, $wanted->[1], $global_opts) | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 4 | for keys %symbols; | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # Returns a coderef suitable to be used as a sub installer for lexical imports. | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | sub _exporter_lexical_installer { | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | _HAS_NATIVE_LEXICAL_SUB and return sub { | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 2 | ▶ | my ( $sigilname, $sym ) = @{ $_[1] }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 17 | ▶ | no warnings ( $] ge '5.037002' ? 'experimental::builtin' : () ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | builtin::export_lexically( $sigilname, $sym ); | |||||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exporter_lexical_installer: called CC=1 SCAR=5.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | _HAS_MODULE_LEXICAL_SUB and return sub { | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | my ( $sigilname, $sym ) = @{ $_[1] }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | ( $sigilname =~ /^\w/ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | ? 'Lexical::Sub'->import( $sigilname, $sym ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | : 'Lexical::Var'->import( $sigilname, $sym ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | _croak( 'Lexical export requires Perl 5.37.2+ for native support, or Perl 5.11.2+ with the Lexical::Sub module' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # Called once per import/unimport, passed the "global" import options. | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # Expected to validate the options and carp or croak if there are problems. | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # Can also take the opportunity to do other stuff if needed. | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 43 | ▶ | sub _exporter_validate_opts { 1 } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exporter_validate_opts: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 4 | ▶ | sub _exporter_validate_unimport_opts { 1 } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exporter_validate_unimport_opts: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # Called after expanding a tag or regexp to merge the tag's options with | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # any sub-specific options. | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | sub _exporter_merge_opts | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 26 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exporter_merge_opts: called CC=12 SCAR=26.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 26 | my ($tag_opts, $global_opts, @stuff) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 26 | ▶ | $tag_opts = {} unless ref($tag_opts) eq q(HASH); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | _croak('Cannot provide an -as option for tags') | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 26 | ▶ | if exists $tag_opts->{-as} && ref $tag_opts->{-as} ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $tag_opts->{"-as"} and ref $tag_opts->{"-as"} ne "CODE"
MC/DC0%0/2
exists $tag_opts->{"-as"} and ref $tag_opts->{"-as"} ne "CODE"
exists $tag_opts->{"-as"}
ref $tag_opts->{"-as"} ne "CODE"
Truth table33%1/3
A and B
A= exists $tag_opts->{"-as"}B= ref $tag_opts->{"-as"} ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 26 | my $optlist = mkopt(\@stuff); | |||||||||||||||||||||||||||||||||||||||||||||
| 169 | 26 | for my $export (@$optlist) | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 52 | ▶ | next if defined($export->[1]) && ref($export->[1]) ne q(HASH); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $export->[1] and ref $export->[1] ne "HASH"
MC/DC0%0/2
defined $export->[1] and ref $export->[1] ne "HASH"
defined $export->[1]
ref $export->[1] ne "HASH"
Truth table66%2/3
A and B
A= defined $export->[1]B= ref $export->[1] ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 52 | ▶ | my %sub_opts = ( %{ $export->[1] or {} }, %$tag_opts ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | $sub_opts{-prefix} = sprintf('%s%s', $tag_opts->{-prefix}, $export->[1]{-prefix}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 52 | ▶ | if exists($export->[1]{-prefix}) && exists($tag_opts->{-prefix}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $export->[1]{"-prefix"} and exists $tag_opts->{"-prefix"}
MC/DC50%1/2
exists $export->[1]{"-prefix"} and exists $tag_opts->{"-prefix"}
exists $export->[1]{"-prefix"}
exists $tag_opts->{"-prefix"}
Truth table66%2/3
A and B
A= exists $export->[1]{"-prefix"}B= exists $tag_opts->{"-prefix"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | $sub_opts{-suffix} = sprintf('%s%s', $export->[1]{-suffix}, $tag_opts->{-suffix}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 52 | ▶ | if exists($export->[1]{-suffix}) && exists($tag_opts->{-suffix}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $export->[1]{"-suffix"} and exists $tag_opts->{"-suffix"}
MC/DC0%0/2
exists $export->[1]{"-suffix"} and exists $tag_opts->{"-suffix"}
exists $export->[1]{"-suffix"}
exists $tag_opts->{"-suffix"}
Truth table66%2/3
A and B
A= exists $export->[1]{"-suffix"}B= exists $tag_opts->{"-suffix"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 52 | $export->[1] = \%sub_opts; | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 26 | return @$optlist; | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # Given a tag name, looks it up in %EXPORT_TAGS and returns the list of | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # associated functions. The default implementation magically handles tags | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # "all" and "default". The default implementation interprets any undefined | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # tags as being global options. | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | sub _exporter_expand_tag | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 17 | ▶ | no strict qw(refs); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 25 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exporter_expand_tag: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 25 | my ($name, $value, $globals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | 25 | my $tags = \%{"$class\::EXPORT_TAGS"}; | |||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | return $class->_exporter_merge_opts($value, $globals, $tags->{$name}->($class, @_)) | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 25 | ▶ | if ref($tags->{$name}) eq q(CODE); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 8 | return $class->_exporter_merge_opts($value, $globals, @{$tags->{$name}}) | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | 25 | ▶ | if exists $tags->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 17 | ▶ | return $class->_exporter_merge_opts($value, $globals, @{"$class\::EXPORT"}, @{"$class\::EXPORT_OK"}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | if $name eq 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 3 | ▶ | return $class->_exporter_merge_opts($value, $globals, @{"$class\::EXPORT"}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | if $name eq 'default'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 2 | ▶ | $globals->{$name} = $value || 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$value || 1
MC/DC100%1/1
$value || 1
$value
Truth table100%2/2
A
A= $value
| |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # Given a regexp-like string, looks it up in @EXPORT_OK and returns the | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # list of matching functions. | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | sub _exporter_expand_regexp | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 17 | ▶ | no strict qw(refs); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 3 | ▶ | our %TRACKED; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exporter_expand_regexp: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 3 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | 3 | my ($name, $value, $globals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 222 | 3 | my $compiled = eval("qr$name"); | |||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | my @possible = $globals->{is_unimport} | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | ? keys( %{$TRACKED{$class}{$globals->{into}}} ) | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | 3 | ▶ | : @{"$class\::EXPORT_OK"}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 3 | $class->_exporter_merge_opts($value, $globals, grep /$compiled/, @possible); | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # Helper for _exporter_expand_sub. Returns a regexp matching all subs in | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # the exporter package which are available for export. | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 234 | sub _exporter_permitted_regexp | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 17 | ▶ | no strict qw(refs); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 47 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exporter_permitted_regexp: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | my $re = join "|", map quotemeta, sort { | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 72 | ▶ | length($b) <=> length($a) or $a cmp $b | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 47 | } @{"$class\::EXPORT"}, @{"$class\::EXPORT_OK"}; | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | 47 | qr{^(?:$re)$}ms; | |||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | # Given a sub name, returns a hash of subs to install (usually just one sub). | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | # Keys are sub names, values are coderefs. | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | sub _exporter_expand_sub | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 67 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exporter_expand_sub: called CC=10 SCAR=23.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 67 | my ($name, $value, $globals, $permitted) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 251 | 67 | ▶ | $permitted ||= $class->_exporter_permitted_regexp($globals); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$permitted ||= $class->_exporter_permitted_regexp($globals)
MC/DC0%0/2
$permitted ||= $class->_exporter_permitted_regexp($globals)
$permitted
$class->_exporter_permitted_regexp($globals)
Truth table33%1/3
A ||= B
A= $permittedB= $class->_exporter_permitted_regexp($globals)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 17 | ▶ | no strict qw(refs); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 67 | my $sigil = "&"; | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | 67 | ▶ | if ($name =~ /\A([&\$\%\@\*])(.+)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 17 | $sigil = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | 17 | $name = $2; | |||||||||||||||||||||||||||||||||||||||||||||
| 259 | 17 | ▶ | if ($sigil eq '*') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | _croak("Cannot export symbols with a * sigil"); | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 67 | ▶ | my $sigilname = $sigil eq '&' ? $name : "$sigil$name"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 67 | ▶ | if ($sigilname =~ $permitted) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 266 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | my $generatorprefix = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | '&' => "_generate_", | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | '$' => "_generateScalar_", | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | '@' => "_generateArray_", | ||||||||||||||||||||||||||||||||||||||||||||||
| 271 | '%' => "_generateHash_", | ||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 65 | }->{$sigil}; | |||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 65 | my $generator = $class->can("$generatorprefix$name"); | |||||||||||||||||||||||||||||||||||||||||||||
| 275 | 65 | ▶ | return $sigilname => $class->$generator($sigilname, $value, $globals) if $generator; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 38 | ▶ | if ($sigil eq '&') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 28 | my $sub = $class->can($name); | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | 28 | ▶ | return $sigilname => $sub if $sub; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 281 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | # Could do this more cleverly, but this works. | ||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 10 | my $evalled = eval "\\${sigil}${class}::${name}"; | |||||||||||||||||||||||||||||||||||||||||||||
| 284 | 10 | ▶ | return $sigilname => $evalled if $evalled; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 3 | $class->_exporter_fail(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | # Called by _exporter_expand_sub if it is unable to generate a key-value | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # pair for a sub. | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 294 | sub _exporter_fail | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 3 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exporter_fail: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 3 | my ($name, $value, $globals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 298 | 3 | ▶ | return if $globals->{is_unimport}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 3 | _croak("Could not find sub '%s' exported by %s", $name, $class); | |||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # Actually performs the installation of the sub into the target package. This | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # also handles renaming the sub. | ||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | sub _exporter_install_sub | ||||||||||||||||||||||||||||||||||||||||||||||
| 306 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 64 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exporter_install_sub: called CC=23 SCAR=32.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 64 | my ($name, $value, $globals, $sym) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 309 | 64 | ▶ | my $value_hash = ( ref($value) eq 'HASH' ) ? $value : {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 64 | my $into = $globals->{into}; | |||||||||||||||||||||||||||||||||||||||||||||
| 312 | 64 | ▶ | my $installer = $globals->{installer} || $globals->{exporter}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$globals->{'installer'} || $globals->{'exporter'}
MC/DC50%1/2
$globals->{'installer'} || $globals->{'exporter'}
$globals->{'installer'}
$globals->{'exporter'}
Truth table66%2/3
A || B
A= $globals->{'installer'}B= $globals->{'exporter'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||
| 314 | $name = | ||||||||||||||||||||||||||||||||||||||||||||||
| 315 | ref $globals->{as} ? $globals->{as}->($name) : | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | ref $value_hash->{-as} ? $value_hash->{-as}->($name) : | ||||||||||||||||||||||||||||||||||||||||||||||
| 317 | exists $value_hash->{-as} ? $value_hash->{-as} : | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 64 | ▶ | $name; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 64 | ▶ | return unless defined $name; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 64 | my $sigil = "&"; | |||||||||||||||||||||||||||||||||||||||||||||
| 323 | 64 | ▶ | unless (ref($name)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 64 | ▶ | if ($name =~ /\A([&\$\%\@\*])(.+)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 16 | $sigil = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 326 | 16 | $name = $2; | |||||||||||||||||||||||||||||||||||||||||||||
| 327 | 16 | ▶ | if ($sigil eq '*') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | _croak("Cannot export symbols with a * sigil"); | |||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 64 | my ($prefix) = grep defined, $value_hash->{-prefix}, $globals->{prefix}, q(); | |||||||||||||||||||||||||||||||||||||||||||||
| 332 | 64 | my ($suffix) = grep defined, $value_hash->{-suffix}, $globals->{suffix}, q(); | |||||||||||||||||||||||||||||||||||||||||||||
| 333 | 64 | $name = "$prefix$name$suffix"; | |||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 64 | ▶ | my $sigilname = $sigil eq '&' ? $name : ( $sigil . $name ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | # if ({qw/$ SCALAR @ ARRAY % HASH & CODE/}->{$sigil} ne ref($sym)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 339 | # warn $sym; | ||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # warn $sigilname; | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | # _croak("Reference type %s does not match sigil %s", ref($sym), $sigil); | ||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # } | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 64 | ▶ | return ($$name = $sym) if ref($name) eq q(SCALAR); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 64 | ▶ | return ($into->{$sigilname} = $sym) if ref($into) eq q(HASH); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 17 | ▶ | no strict qw(refs); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 50 | our %TRACKED; | |||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 50 | ▶ | if ( ref($sym) eq 'CODE' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%6/6
ref $sym eq "CODE" and ref $into ? exists $into->{$name} : exists &{"${into}::$name";} and $sym != (ref $into ? $into->{$name} : \&{"${into}::$name";})
ref $sym eq "CODE" and ref $into ? exists $into->{$name} : exists &{"${into}::$name";}
MC/DC100%3/3
ref $sym eq "CODE" and ref $into ? exists $into->{$name} : exists &{"${into}::$name";} and $sym != (ref $into ? $into->{$name} : \&{"${into}::$name";})
ref $sym eq "CODE"
ref $into ? exists $into->{$name} : exists &{"${into}::$name";}
$sym != (ref $into ? $into->{$name} : \&{"${into}::$name";})
Truth table100%4/4
A and B and C
A= ref $sym eq "CODE"B= ref $into ? exists $into->{$name} : exists &{"${into}::$name";}C= $sym != (ref $into ? $into->{$name} : \&{"${into}::$name";})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 40 | ▶ | and ref($into) ? exists($into->{$name}) : exists(&{"$into\::$name"}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 5 | and $sym != ( ref($into) ? $into->{$name} : \&{"$into\::$name"} ) ) | |||||||||||||||||||||||||||||||||||||||||||||
| 353 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 4 | my ($level) = grep defined, $value_hash->{-replace}, $globals->{replace}, q(0); | |||||||||||||||||||||||||||||||||||||||||||||
| 355 | my $action = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | carp => \&_carp, | ||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 => \&_carp, | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | '' => \&_carp, | ||||||||||||||||||||||||||||||||||||||||||||||
| 359 | warn => \&_carp, | ||||||||||||||||||||||||||||||||||||||||||||||
| 360 | nonfatal => \&_carp, | ||||||||||||||||||||||||||||||||||||||||||||||
| 361 | croak => \&_croak, | ||||||||||||||||||||||||||||||||||||||||||||||
| 362 | fatal => \&_croak, | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | die => \&_croak, | ||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 4 | ▶ | }->{$level} || sub {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Condition33%1/3
{'carp', \&Exporter::Tiny::_carp, 0, \&Exporter::Tiny::_carp, '', \&Exporter::Tiny::_carp, 'warn', \&Exporter::Tiny::_carp, 'nonfatal', \&Exporter::Tiny::_carp, 'croak', \&Exporter::Tiny::_croak, 'fatal', \&Exporter::Tiny::_croak, 'die', \&Exporter::Tiny::_croak}->{$level} || sub {
}
MC/DC0%0/2
{'carp', \&Exporter::Tiny::_carp, 0, \&Exporter::Tiny::_carp, '', \&Exporter::Tiny::_carp, 'warn', \&Exporter::Tiny::_carp, 'nonfatal', \&Exporter::Tiny::_carp, 'croak', \&Exporter::Tiny::_croak, 'fatal', \&Exporter::Tiny::_croak, 'die', \&Exporter::Tiny::_croak}->{$level} || sub {
}
{'carp', \&Exporter::Tiny::_carp, 0, \&Exporter::Tiny::_carp, '', \&Exporter::Tiny::_carp, 'warn', \&Exporter::Tiny::_carp, 'nonfatal', \&Exporter::Tiny::_carp, 'croak', \&Exporter::Tiny::_croak, 'fatal', \&Exporter::Tiny::_croak, 'die', \&Exporter::Tiny::_croak}->{$level}
sub {
}
Truth table33%1/3
A || B
A= {'carp', \&Exporter::Tiny::_carp, 0, \&Exporter::Tiny::_carp, '', \&Exporter::Tiny::_carp, 'warn', \&Exporter::Tiny::_carp, 'nonfatal', \&Exporter::Tiny::_carp, 'croak', \&Exporter::Tiny::_croak, 'fatal', \&Exporter::Tiny::_croak, 'die', \&Exporter::Tiny::_croak}->{$level}B= sub {
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # Don't complain about double-installing the same sub. This isn't ideal | ||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # because the same named sub might be generated in two different ways. | ||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 4 | ▶ | $action = sub {} if $TRACKED{$class}{$into}{$sigilname}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 4 | ▶ | $action->( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 371 | $action == \&_croak | ||||||||||||||||||||||||||||||||||||||||||||||
| 372 | ? "Refusing to overwrite existing sub '%s' with sub '%s' exported by %s" | ||||||||||||||||||||||||||||||||||||||||||||||
| 373 | : "Overwriting existing sub '%s' with sub '%s' exported by %s", | ||||||||||||||||||||||||||||||||||||||||||||||
| 374 | ref($into) ? $name : "$into\::$name", | ||||||||||||||||||||||||||||||||||||||||||||||
| 375 | $_[0], | ||||||||||||||||||||||||||||||||||||||||||||||
| 376 | $class, | ||||||||||||||||||||||||||||||||||||||||||||||
| 377 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 48 | $TRACKED{$class}{$into}{$sigilname} = $sym; | |||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 17 | ▶ | no warnings qw(prototype); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | $installer | ||||||||||||||||||||||||||||||||||||||||||||||
| 384 | ? $installer->($globals, [$sigilname, $sym]) | ||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 48 | ▶ | : (*{"$into\::$name"} = $sym); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||
| 388 | sub _exporter_uninstall_sub | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 4 | ▶ | our %TRACKED; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exporter_uninstall_sub: called CC=10 SCAR=23.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 4 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 392 | 4 | my ($name, $value, $globals, $sym) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 393 | 4 | my $into = $globals->{into}; | |||||||||||||||||||||||||||||||||||||||||||||
| 394 | 4 | ▶ | ref $into and return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 17 | ▶ | no strict qw(refs); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 4 | my $sigil = "&"; | |||||||||||||||||||||||||||||||||||||||||||||
| 399 | 4 | ▶ | if ($name =~ /\A([&\$\%\@\*])(.+)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 1 | $sigil = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 401 | 1 | $name = $2; | |||||||||||||||||||||||||||||||||||||||||||||
| 402 | 1 | ▶ | if ($sigil eq '*') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | _croak("Cannot export symbols with a * sigil"); | |||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 4 | ▶ | my $sigilname = $sigil eq '&' ? $name : "$sigil$name"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 4 | ▶ | if ($sigil ne '&') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 1 | _croak("Unimporting non-code symbols not supported yet"); | |||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | # Cowardly refuse to uninstall a sub that differs from the one | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | # we installed! | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 3 | my $our_coderef = $TRACKED{$class}{$into}{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 415 | 3 | ▶ | my $cur_coderef = exists(&{"$into\::$name"}) ? \&{"$into\::$name"} : -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 3 | ▶ | return unless $our_coderef == $cur_coderef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 3 | my $stash = \%{"$into\::"}; | |||||||||||||||||||||||||||||||||||||||||||||
| 419 | 3 | my $old = delete $stash->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 420 | 3 | my $full_name = join('::', $into, $name); | |||||||||||||||||||||||||||||||||||||||||||||
| 421 | 3 | foreach my $type (qw(SCALAR HASH ARRAY IO)) # everything but the CODE | |||||||||||||||||||||||||||||||||||||||||||||
| 422 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 12 | ▶ | next unless defined(*{$old}{$type}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 3 | *$full_name = *{$old}{$type}; | |||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 3 | delete $TRACKED{$class}{$into}{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||
| 430 | sub mkopt | ||||||||||||||||||||||||||||||||||||||||||||||
| 431 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 73 | ▶ | my $in = shift or return []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mkopt: called CC=8 SCAR=21.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 73 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 73 | ▶ | $in = [map(($_ => ref($in->{$_}) ? $in->{$_} : ()), sort keys %$in)] | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 436 | if ref($in) eq q(HASH); | ||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 73 | ▶ | for (my $i = 0; $i < @$in; $i++) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 439 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 115 | my $k = $in->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 441 | 115 | my $v; | |||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 115 | ▶ | ($i == $#$in) ? ($v = undef) : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 444 | !defined($in->[$i+1]) ? (++$i, ($v = undef)) : | ||||||||||||||||||||||||||||||||||||||||||||||
| 445 | !ref($in->[$i+1]) ? ($v = undef) : | ||||||||||||||||||||||||||||||||||||||||||||||
| 446 | ($v = $in->[++$i]); | ||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 115 | push @out, [ $k => $v ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 73 | \@out; | |||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||
| 454 | sub mkopt_hash | ||||||||||||||||||||||||||||||||||||||||||||||
| 455 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | my $in = shift or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mkopt_hash: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my %out = map +($_->[0] => $_->[1]), @{ mkopt($in) }; | |||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | \%out; | |||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 17 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||
| 463 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||