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