| 1 | package Exporter::Handy::Util; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Routines useful when exporting symbols thru Exporter and friends | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | our $VERSION = '1.000002'; | |||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | # Automatically fall back to pure perl for older versions of List::Util (circa Perl version < 5.20) | ||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use List::Util::MaybeXS qw( pairs unpairs uniq ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Exporter::Extensible -exporter_setup => 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | export(qw( | |||||||||||||||||||||||||||||||||||||||||
| 15 | =xtags | ||||||||||||||||||||||||||||||||||||||||||
| 16 | =expand_xtags | ||||||||||||||||||||||||||||||||||||||||||
| 17 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | # Generators for exported functions | ||||||||||||||||||||||||||||||||||||||||||
| 21 | sub _generate_xtags { | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | my ($exporter, $symbol, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_xtags: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 6 | ▶ | sub {; xtags_($opts // {}, @_ ) } # curried | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Condition100%2/2
$opts // {}
MC/DC100%1/1
$opts // {}
$opts
Truth table100%2/2
A
A= $opts
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | } | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | sub _generate_expand_xtags { | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my ($exporter, $symbol, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_expand_xtags: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub {; expand_xtags_(@_, $opts // { }) } # curried | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$opts // {}
MC/DC0%0/1
$opts // {}
$opts
Truth table0%0/2
A
A= $opts
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | sub xtags_ { # useful for building export tags | ||||||||||||||||||||||||||||||||||||||||||
| 35 | # say STDERR 'xtag ARGS: ' . np(@_); | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 6 | ▶ | my %opt; %opt = ( %opt, %{; shift } ) while _is_plain_hashref($_[0]); # merge options given by any leading hash-refs | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xtags_: called CC=5 SCAR=16.1
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | my @res; | |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 6 | for (pairs @_) { | |||||||||||||||||||||||||||||||||||||||||
| 42 | 6 | my ($k ,$v) = @$_; | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 6 | ▶ | if ( ref($v) =~ /^HASH$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 4 | push @res, _xtag_group( \%opt, $k => $v ); | |||||||||||||||||||||||||||||||||||||||||
| 46 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | push @res, _xtag_group( \%opt, '' => { $k => $v } ); | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 6 | ▶ | wantarray ? @res : \@res; ## no critic | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | sub _xtag_group { | ||||||||||||||||||||||||||||||||||||||||||
| 54 | # say STDERR '_xtag_group ARGS: ' . np(@_); | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | # options may be given by one or more leading hash-refs (that we merge) | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 8 | ▶ | my %opt; %opt = ( %opt, %{; shift } ) while _is_plain_hashref($_[0]); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_xtag_group: called CC=29 SCAR=36.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 8 | ▶ | my $group = ( @_ && !ref( $_[0] ) ) ? shift : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ and not ref $_[0]
MC/DC0%0/2
@_ and not ref $_[0]
@_
not ref $_[0]
Truth table33%1/3
A and not(B)
A= @_B= not ref $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 8 | my %items = %{; shift }; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 8 | ▶ | %opt = ( %opt, %{; delete $items{'%'} // {} } ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $items{"%"} // {}
MC/DC0%0/1
delete $items{"%"} // {}
delete $items{"%"}
Truth table50%1/2
A
A= delete $items{"%"}
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 8 | ▶ | $group = $group // delete $opt{group} // delete $opt{name} // ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition37%3/8
(($group // delete $opt{"group"}) // delete $opt{"name"}) // ""
($group // delete $opt{"group"}) // delete $opt{"name"}
$group // delete $opt{"group"}
MC/DC0%0/3
(($group // delete $opt{"group"}) // delete $opt{"name"}) // ""
$group
delete $opt{"group"}
delete $opt{"name"}
Truth table25%1/4
A // B // C
A= $groupB= delete $opt{"group"}C= delete $opt{"name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 8 | $group =~ s/^([:])//; | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 8 | my %subopt= %opt; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 8 | ▶ | my $sig = delete $opt{sig} // $1 // ''; # like a sigil... It's typically either ':' or empty string. | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
(delete $opt{"sig"} // $1) // ""
delete $opt{"sig"} // $1
MC/DC100%2/2
(delete $opt{"sig"} // $1) // ""
delete $opt{"sig"}
$1
Truth table100%3/3
A // B
A= delete $opt{"sig"}B= $1
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 8 | ▶ | my $sep = delete $opt{sep} // '_'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opt{"sep"} // "_"
MC/DC0%0/1
delete $opt{"sep"} // "_"
delete $opt{"sep"}
Truth table50%1/2
A
A= delete $opt{"sep"}
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 8 | ▶ | my $nogroup = delete $opt{nogroup} // 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opt{"nogroup"} // 0
MC/DC0%0/1
delete $opt{"nogroup"} // 0
delete $opt{"nogroup"}
Truth table50%1/2
A
A= delete $opt{"nogroup"}
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 8 | ▶ | my @pfx = _flat( delete $opt{pfx} // ( $group ? "${group}${sep}" : "" )); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
delete $opt{"pfx"} // ($group ? "$group$sep" : "")
MC/DC50%1/2
delete $opt{"pfx"} // ($group ? "$group$sep" : "")
delete $opt{"pfx"}
($group ? "$group$sep" : "")
Truth table66%2/3
A // B
A= delete $opt{"pfx"}B= ($group ? "$group$sep" : "")
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 8 | my %tags; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 8 | for my $pfx (@pfx) { | |||||||||||||||||||||||||||||||||||||||||
| 75 | 8 | ▶ | $pfx = $sig . $pfx if $sig && ($pfx !~ /^\Q$sig\E/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$sig and not $pfx =~ /^\Q$sig\E/
MC/DC50%1/2
$sig and not $pfx =~ /^\Q$sig\E/
$sig
not $pfx =~ /^\Q$sig\E/
Truth table66%2/3
A and not(B)
A= $sigB= not $pfx =~ /^\Q$sig\E/
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 8 | for my $k (sort keys %items) { | |||||||||||||||||||||||||||||||||||||||||
| 78 | 8 | my $v = $items{$k}; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 8 | $k =~ s/^\Q$sig\E//; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 8 | my $key = "${pfx}${k}"; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 8 | ▶ | my %subtags = ( ref($v) =~ /^HASH$/ ) ? ( _xtag_group(\%subopt, $key => $v) ) : ( $key => $v); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 8 | %tags = (%tags, %subtags); | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | # umbrella entry (that encompasses all subtags) | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 8 | ▶ | if (!$nogroup && defined $group && $group) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
not $nogroup and defined $group and $group
not $nogroup and defined $group
MC/DC33%1/3
not $nogroup and defined $group and $group
not $nogroup
defined $group
$group
Truth table50%2/4
not(A) and B and C
A= not $nogroupB= defined $groupC= $group
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 6 | my $g = $group; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 6 | ▶ | $g = $sig . $g if $sig && ($g !~ /^\Q$sig\E/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$sig and not $g =~ /^\Q$sig\E/
MC/DC50%1/2
$sig and not $g =~ /^\Q$sig\E/
$sig
not $g =~ /^\Q$sig\E/
Truth table66%2/3
A and not(B)
A= $sigB= not $g =~ /^\Q$sig\E/
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | $tags{$g} = [ | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 6 | map {; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 8 | my $item = $_; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 8 | ▶ | $item = ':' . $_ if defined $_ && $_ && !m/^[:]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $_ and $_ and not /^[:]/
defined $_ and $_
MC/DC33%1/3
defined $_ and $_ and not /^[:]/
defined $_
$_
not /^[:]/
Truth table50%2/4
A and B and not(C)
A= defined $_B= $_C= not /^[:]/
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 8 | ▶ | $item // () | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$item // ()
MC/DC0%0/2
$item // ()
$item
()
Truth table33%1/3
A // B
A= $itemB= ()
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | } ( sort keys %tags ) ] | ||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 8 | my @tags = _kv_sort(%tags); # sort on keys | |||||||||||||||||||||||||||||||||||||||||
| 98 | 8 | ▶ | wantarray ? @tags : \@tags; ## no critic | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | sub expand_xtags_ { | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | local $_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand_xtags_: not called CC=17 SCAR=57.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | my %tags; %tags = ( %tags, %{; shift } ) while _is_plain_hashref($_[0]); # tags at start | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | my %opt; %opt = ( %opt, %{; pop } ) while _is_plain_hashref($_[-1]); # options at the end. | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | # Handle special requests given via options | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | my @keys = _flat( delete $opt{key} // (), delete $opt{keys} // () ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
delete $opt{"key"} // ()
delete $opt{"keys"} // ()
MC/DC0%0/2
delete $opt{"key"} // ()
delete $opt{"key"}
()
MC/DC0%0/2
delete $opt{"keys"} // ()
delete $opt{"keys"}
()
Truth table0%0/3
A // B
A= delete $opt{"key"}B= ()
Truth table0%0/3
A // B
A= delete $opt{"keys"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | for (@keys) { | |||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if (_is_plain_scalarref($_) and ($$_ =~ /[*]|ALL/i ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
_is_plain_scalarref($_) and $$_ =~ /[*]|ALL/i
MC/DC0%0/2
_is_plain_scalarref($_) and $$_ =~ /[*]|ALL/i
_is_plain_scalarref($_)
$$_ =~ /[*]|ALL/i
Truth table0%0/3
A and B
A= _is_plain_scalarref($_)B= $$_ =~ /[*]|ALL/i
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | # A scalar ref indicates special handling! | ||||||||||||||||||||||||||||||||||||||||||
| 113 | # If it deferences to '*' (or 'ALL'), it means "ALL KEYS". | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | push @_, values %tags; | |||||||||||||||||||||||||||||||||||||||||
| 115 | next | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | push @_, $tags{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | @_ = uniq(@_); | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||
| 122 | my @res; | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | while (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $_ = shift; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | next unless defined; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | ref($_) eq 'ARRAY' and do { unshift @_, @$_; next }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | next if exists $seen{$_} && ( $seen{$_} // 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
exists $seen{$_} and $seen{$_} // 0
$seen{$_} // 0
MC/DC0%0/2
exists $seen{$_} and $seen{$_} // 0
exists $seen{$_}
$seen{$_}
Truth table0%0/3
A and B
A= exists $seen{$_}B= $seen{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $seen{$_} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | m/^([:](.*))$/ and do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | unshift @_, delete $tags{$1} // (), delete $tags{$2} // (); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
delete $tags{$1} // ()
delete $tags{$2} // ()
MC/DC0%0/2
delete $tags{$1} // ()
delete $tags{$1}
()
MC/DC0%0/2
delete $tags{$2} // ()
delete $tags{$2}
()
Truth table0%0/3
A // B
A= delete $tags{$1}B= ()
Truth table0%0/3
A // B
A= delete $tags{$2}B= ()
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 135 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | push @res, $_; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | @res | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | # PRIVATE routines | ||||||||||||||||||||||||||||||||||||||||||
| 143 | # ref | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 8 | ▶ | sub _is_plain_arrayref { ref( $_[0] ) eq 'ARRAY' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_plain_arrayref: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 28 | ▶ | sub _is_plain_hashref { ref( $_[0] ) eq 'HASH' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_plain_hashref: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | sub _is_plain_scalarref { ref( $_[0] ) eq 'SCALAR' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_plain_scalarref: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | sub _is_plain_scalar { !ref( $_[0] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_plain_scalar: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | # List | ||||||||||||||||||||||||||||||||||||||||||
| 150 | sub _flat { # shamelessly copied from: [List::_flat](https://metacpan.org/pod/List::_flat) | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 8 | ▶ | my @results; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_flat: called CC=4 SCAR=15.0
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 8 | ▶ | while (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 8 | ▶ | if ( _is_plain_arrayref( my $element = shift @_ ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | unshift @_, @{$element}; | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 8 | push @results, $element; | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 8 | ▶ | return wantarray ? @results : \@results; ## no critic | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | sub _kv_sort { | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 8 | ▶ | unpairs sort { $a->[0] cmp $b->[0] } pairs(@_) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_kv_sort: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | __END__ | ||||||||||||||||||||||||||||||||||||||||||