| 1 | package List::MoreUtils::PP; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 122 | ▶ | use 5.008_001; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 122 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 122 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 122 | our $VERSION = '0.429_001'; | |||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | List::MoreUtils::PP - Provide List::MoreUtils pure Perl implementation | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | BEGIN { $ENV{LIST_MOREUTILS_PP} = 1; } | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | use List::MoreUtils qw(:all); | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ## no critic (Subroutines::ProhibitSubroutinePrototypes, Subroutines::RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ## no critic (Subroutines::ProhibitManyArgs) | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | sub any (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 13 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 13 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 40005 | ▶ | return 1 if $f->(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | sub all (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 9 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 9 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 25005 | ▶ | return 0 unless $f->(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | sub none (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 9 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
none: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 9 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 40002 | ▶ | return 0 if $f->(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | sub notall (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 9 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
notall: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 9 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 59 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 20006 | ▶ | return 1 unless $f->(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | sub one (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 12 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
one: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 12 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | 12 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 2063 | ▶ | $f->() and $found++ and return 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
&$f() and $found++
MC/DC100%2/2
&$f() and $found++
&$f()
$found++
Truth table100%3/3
A and B
A= &$f()B= $found++
| |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 5 | return $found; | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | sub any_u (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 13 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_u: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 13 | ▶ | return if !@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 12 | ▶ | $f->() and return 1 foreach (@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | sub all_u (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 9 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_u: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 9 | ▶ | return if !@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 8 | ▶ | $f->() or return 0 foreach (@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | sub none_u (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 9 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
none_u: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 9 | ▶ | return if !@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 8 | ▶ | $f->() and return 0 foreach (@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | sub notall_u (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 9 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
notall_u: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 9 | ▶ | return if !@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 8 | ▶ | $f->() or return 1 foreach (@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | sub one_u (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 12 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
one_u: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 12 | ▶ | return if !@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 11 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | 11 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2063 | ▶ | $f->() and $found++ and return 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
&$f() and $found++
MC/DC100%2/2
&$f() and $found++
&$f()
$found++
Truth table100%3/3
A and B
A= &$f()B= $found++
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 4 | return $found; | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | sub reduce_u(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 8 | ▶ | my $code = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reduce_u: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # Localise $a, $b | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | my ($caller_a, $caller_b) = do | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 8 | { | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | 8 | my $pkg = caller(); | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | ## no critic (TestingAndDebugging::ProhibitNoStrict, ValuesAndExpressions::ProhibitCommaSeparatedStatements) | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 122 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 8 | \*{$pkg . '::a'}, \*{$pkg . '::b'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | ## no critic (Variables::RequireInitializationForLocalVars) | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 8 | local (*$caller_a, *$caller_b); | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | 8 | *$caller_a = \(); | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 8 | for (0 .. $#_) | |||||||||||||||||||||||||||||||||||||||||||||
| 137 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 224 | *$caller_b = \$_[$_]; | |||||||||||||||||||||||||||||||||||||||||||||
| 139 | 224 | *$caller_a = \($code->()); | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 5 | return ${*$caller_a}; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | sub reduce_0(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 9 | ▶ | my $code = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reduce_0: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # Localise $a, $b | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | my ($caller_a, $caller_b) = do | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 9 | { | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | 9 | my $pkg = caller(); | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | ## no critic (TestingAndDebugging::ProhibitNoStrict, ValuesAndExpressions::ProhibitCommaSeparatedStatements) | ||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 122 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 9 | \*{$pkg . '::a'}, \*{$pkg . '::b'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ## no critic (Variables::RequireInitializationForLocalVars) | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 9 | local (*$caller_a, *$caller_b); | |||||||||||||||||||||||||||||||||||||||||||||
| 160 | 9 | *$caller_a = \0; | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | 9 | for (0 .. $#_) | |||||||||||||||||||||||||||||||||||||||||||||
| 162 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 231 | *$caller_b = \$_[$_]; | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | 231 | *$caller_a = \($code->()); | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 6 | return ${*$caller_a}; | |||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | sub reduce_1(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | ▶ | my $code = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reduce_1: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # Localise $a, $b | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | my ($caller_a, $caller_b) = do | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | { | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | my $pkg = caller(); | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | ## no critic (TestingAndDebugging::ProhibitNoStrict, ValuesAndExpressions::ProhibitCommaSeparatedStatements) | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 122 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | \*{$pkg . '::a'}, \*{$pkg . '::b'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | ## no critic (Variables::RequireInitializationForLocalVars) | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | local (*$caller_a, *$caller_b); | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | *$caller_a = \1; | |||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | for (0 .. $#_) | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 750 | *$caller_b = \$_[$_]; | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | 750 | *$caller_a = \($code->()); | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | return ${*$caller_a}; | |||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | sub true (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 10 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
true: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 10 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | 10 | ▶ | $f->() and ++$count foreach (@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 9 | return $count; | |||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | sub false (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 10 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
false: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 10 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 207 | 10 | ▶ | $f->() or ++$count foreach (@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 9 | return $count; | |||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | sub firstidx (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 31 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
firstidx: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 31 | foreach my $i (0 .. $#_) | |||||||||||||||||||||||||||||||||||||||||||||
| 215 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 50060 | local *_ = \$_[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 217 | 50060 | ▶ | return $i if $f->(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 5 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | sub firstval (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 8 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
firstval: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 8 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 21 | ▶ | return $_ if $test->(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ## no critic (Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 3 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | sub firstres (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 234 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 7 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
firstres: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 7 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 21 | my $testval = $test->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | 20 | ▶ | $testval and return $testval; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | ## no critic (Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 2 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | sub onlyidx (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 17 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
onlyidx: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 17 | my $found; | |||||||||||||||||||||||||||||||||||||||||||||
| 249 | 17 | foreach my $i (0 .. $#_) | |||||||||||||||||||||||||||||||||||||||||||||
| 250 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 3521 | local *_ = \$_[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 252 | 3521 | ▶ | $f->() or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 22 | ▶ | defined $found and return -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 14 | $found = $i; | |||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 8 | ▶ | return defined $found ? $found : -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||
| 259 | sub onlyval (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 17 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
onlyval: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 17 | my $result = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 263 | 17 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 264 | 17 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 265 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 3521 | ▶ | $test->() or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 22 | $result = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 268 | ## no critic (Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 22 | ▶ | $found++ and return undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 8 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | sub onlyres (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 15 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
onlyres: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 15 | my $result = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 278 | 15 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | 15 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 280 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 2921 | ▶ | my $rv = $test->() or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 20 | $result = $rv; | |||||||||||||||||||||||||||||||||||||||||||||
| 283 | ## no critic (Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 20 | ▶ | $found++ and return undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 6 | ▶ | return $found ? $result : undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||
| 289 | sub lastidx (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 13 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lastidx: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 13 | foreach my $i (reverse 0 .. $#_) | |||||||||||||||||||||||||||||||||||||||||||||
| 293 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 20009 | local *_ = \$_[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 295 | 20009 | ▶ | return $i if $f->(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 4 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||
| 300 | sub lastval (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 8 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lastval: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 8 | my $ix; | |||||||||||||||||||||||||||||||||||||||||||||
| 304 | 8 | ▶ | for ($ix = $#_; $ix >= 0; $ix--) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 305 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 13 | local *_ = \$_[$ix]; | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | 13 | my $testval = $test->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | # Simulate $_ as alias | ||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 12 | $_[$ix] = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 311 | 12 | ▶ | return $_ if $testval; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 313 | ## no critic (Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 3 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||
| 317 | sub lastres (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 7 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lastres: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 7 | my $ix; | |||||||||||||||||||||||||||||||||||||||||||||
| 321 | 7 | ▶ | for ($ix = $#_; $ix >= 0; $ix--) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 322 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 13 | local *_ = \$_[$ix]; | |||||||||||||||||||||||||||||||||||||||||||||
| 324 | 13 | my $testval = $test->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||
| 326 | # Simulate $_ as alias | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 12 | $_[$ix] = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 328 | 12 | ▶ | return $testval if $testval; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 330 | ## no critic (Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 2 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||
| 334 | sub insert_after (&$\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 11 | ▶ | my ($f, $val, $list) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_after: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 11 | my $c = &firstidx($f, @$list); | |||||||||||||||||||||||||||||||||||||||||||||
| 338 | 6 | ▶ | @$list = (@{$list}[0 .. $c], $val, @{$list}[$c + 1 .. $#$list],) and return 1 if $c != -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$c != -1 && ((@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])) && (return 1))
@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*]) and return 1
MC/DC0%0/2
$c != -1 && ((@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])) && (return 1))
$c != -1
@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])
Truth table33%1/3
A && B
A= $c != -1B= @$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])
| |||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||
| 342 | sub insert_after_string ($$\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 10 | ▶ | my ($string, $val, $list) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_after_string: called CC=3 SCAR=11.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 10 | ▶ | my $c = firstidx { defined $_ and $string eq $_ } @$list; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 7 | ▶ | @$list = (@{$list}[0 .. $c], $val, @{$list}[$c + 1 .. $#$list],) and return 1 if $c != -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
$c != -1 && ((@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])) && (return 1))
@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*]) and return 1
MC/DC0%0/2
$c != -1 && ((@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])) && (return 1))
$c != -1
@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])
Truth table0%0/3
A && B
A= $c != -1B= @$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])
| |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||
| 350 | sub apply (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 351 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 11 | ▶ | my $action = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 11 | &$action foreach my @values = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 354 | 8 | ▶ | return wantarray ? @values : $values[-1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||
| 357 | sub after (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 7 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 7 | my $started; | |||||||||||||||||||||||||||||||||||||||||||||
| 361 | my $lag; | ||||||||||||||||||||||||||||||||||||||||||||||
| 362 | ## no critic (BuiltinFunctions::RequireBlockGrep) | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | return grep $started ||= do | ||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$started ||= do {
my $x = $lag;
$lag = &$test();
$x
}
MC/DC100%2/2
$started ||= do {
my $x = $lag;
$lag = &$test();
$x
}
$started
do {
my $x = $lag;
$lag = &$test();
$x
}
Truth table100%3/3
A ||= B
A= $startedB= do {
my $x = $lag;
$lag = &$test();
$x
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 19 | my $x = $lag; | |||||||||||||||||||||||||||||||||||||||||||||
| 366 | 19 | $lag = $test->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 367 | 18 | $x; | |||||||||||||||||||||||||||||||||||||||||||||
| 368 | }, @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||
| 371 | sub after_incl (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 372 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 6 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_incl: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 6 | my $started; | |||||||||||||||||||||||||||||||||||||||||||||
| 375 | 6 | ▶ | return grep { $started ||= $test->() } @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$started ||= &$test()
MC/DC100%2/2
$started ||= &$test()
$started
&$test()
Truth table100%3/3
A ||= B
A= $startedB= &$test()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||
| 378 | sub before (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 6 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
before: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 6 | my $more = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 382 | 6 | ▶ | return grep { $more &&= !$test->() } @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$more &&= !&$test()
MC/DC100%2/2
$more &&= !&$test()
$more
!&$test()
Truth table100%3/3
A &&= not(B)
A= $moreB= !&$test()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||
| 385 | sub before_incl (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 386 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 6 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
before_incl: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 6 | my $more = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 389 | 6 | my $lag = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 390 | ## no critic (BuiltinFunctions::RequireBlockGrep) | ||||||||||||||||||||||||||||||||||||||||||||||
| 391 | return grep $more &&= do | ||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$more &&= do {
my $x = $lag;
$lag = !&$test();
$x
}
MC/DC100%2/2
$more &&= do {
my $x = $lag;
$lag = !&$test();
$x
}
$more
do {
my $x = $lag;
$lag = !&$test();
$x
}
Truth table100%3/3
A &&= B
A= $moreB= do {
my $x = $lag;
$lag = !&$test();
$x
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 18 | my $x = $lag; | |||||||||||||||||||||||||||||||||||||||||||||
| 394 | 18 | $lag = !$test->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 395 | 17 | $x; | |||||||||||||||||||||||||||||||||||||||||||||
| 396 | }, @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||
| 399 | sub indexes (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 400 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 24 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
indexes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | return grep { | ||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 24 | local *_ = \$_[$_]; | |||||||||||||||||||||||||||||||||||||||||||||
| 404 | 144 | $test->() | |||||||||||||||||||||||||||||||||||||||||||||
| 405 | } 0 .. $#_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | sub pairwise (&\@\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 409 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 12 | ▶ | my $op = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pairwise: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | # Symbols for caller's input arrays | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 122 | ▶ | use vars qw{ @A @B }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 12 | local (*A, *B) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | # Localise $a, $b | ||||||||||||||||||||||||||||||||||||||||||||||
| 417 | my ($caller_a, $caller_b) = do | ||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 12 | { | |||||||||||||||||||||||||||||||||||||||||||||
| 419 | 12 | my $pkg = caller(); | |||||||||||||||||||||||||||||||||||||||||||||
| 420 | ## no critic (TestingAndDebugging::ProhibitNoStrict, ValuesAndExpressions::ProhibitCommaSeparatedStatements) | ||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 122 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 12 | \*{$pkg . '::a'}, \*{$pkg . '::b'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 423 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # Loop iteration limit | ||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 12 | ▶ | my $limit = $#A > $#B ? $#A : $#B; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||
| 428 | ## no critic (Variables::RequireInitializationForLocalVars) | ||||||||||||||||||||||||||||||||||||||||||||||
| 429 | # This map expression is also the return value | ||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 12 | local (*$caller_a, *$caller_b); | |||||||||||||||||||||||||||||||||||||||||||||
| 431 | ## no critic (BuiltinFunctions::ProhibitComplexMappings) | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | # Assign to $a, $b as refs to caller's array elements | ||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 12 | ▶ | (*$caller_a, *$caller_b) = \($#A < $_ ? undef : $A[$_], $#B < $_ ? undef : $B[$_]); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # Perform the transformation | ||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 691 | $op->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 438 | } 0 .. $limit; | ||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||
| 441 | sub each_array (\@;\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 442 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 10 | ▶ | return each_arrayref(@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
each_array: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||
| 446 | sub each_arrayref | ||||||||||||||||||||||||||||||||||||||||||||||
| 447 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 18 | ▶ | my @list = @_; # The list of references to the arrays | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
each_arrayref: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 18 | my $index = 0; # Which one the caller will get next | |||||||||||||||||||||||||||||||||||||||||||||
| 450 | 18 | my $max = 0; # Number of elements in longest array | |||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||
| 452 | # Get the length of the longest input array | ||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 18 | foreach (@list) | |||||||||||||||||||||||||||||||||||||||||||||
| 454 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 26 | ▶ | unless (ref $_ eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 456 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 2 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||
| 458 | 2 | Carp::croak("each_arrayref: argument is not an array reference\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 24 | ▶ | $max = @$_ if @$_ > $max; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # Return the iterator as a closure wrt the above variables. | ||||||||||||||||||||||||||||||||||||||||||||||
| 464 | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 108 | ▶ | if (@_) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=19.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 466 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 10 | my $method = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 468 | 10 | ▶ | unless ($method eq 'index') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 469 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | Carp::croak("each_array: unknown argument '$method' passed to iterator."); | |||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||
| 474 | ## no critic (Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 10 | ▶ | return undef if $index == 0 || $index > $max; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$index == 0 or $index > $max
MC/DC0%0/2
$index == 0 or $index > $max
$index == 0
$index > $max
Truth table33%1/3
A or B
A= $index == 0B= $index > $max
| |||||||||||||||||||||||||||||||||||||||||||||||
| 476 | # Return current (last fetched) index | ||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 10 | return $index - 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||
| 480 | # No more elements to return | ||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 98 | ▶ | return if $index >= $max; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 82 | my $i = $index++; | |||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # Return ith elements | ||||||||||||||||||||||||||||||||||||||||||||||
| 485 | ## no critic (BuiltinFunctions::RequireBlockMap) | ||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 82 | return map $_->[$i], @list; | |||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 16 | } | |||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||
| 490 | sub natatime ($@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 491 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 4 | ▶ | my $n = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
natatime: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 4 | my @list = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 494 | 1009 | ▶ | return sub { return splice @list, 0, $n; } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 4 | } | |||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||
| 497 | # "leaks" when lexically hidden in arrayify | ||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 122 | my $flatten; | |||||||||||||||||||||||||||||||||||||||||||||
| 499 | $flatten = sub { | ||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 165 | ▶ | return map { (ref $_ and ("ARRAY" eq ref $_ or overload::Method($_, '@{}'))) ? ($flatten->(@{$_})) : ($_) } @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
Branch: 1 branch
Condition83%5/6
ref $_ and "ARRAY" eq ref $_ || overload::Method($_, "\@{}")
"ARRAY" eq ref $_ or overload::Method($_, "\@{}")
MC/DC66%2/3
ref $_ and "ARRAY" eq ref $_ || overload::Method($_, "\@{}")
ref $_
"ARRAY" eq ref $_
overload::Method($_, "\@{}")
Truth table75%3/4
A and B or C
A= ref $_B= "ARRAY" eq ref $_C= overload::Method($_, "\@{}")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 122 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||
| 503 | sub arrayify | ||||||||||||||||||||||||||||||||||||||||||||||
| 504 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 15 | ▶ | return map { $flatten->($_) } @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arrayify: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||
| 508 | sub mesh (\@\@;\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 509 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 26 | ▶ | my $max = -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mesh: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 26 | ▶ | $max < $#$_ && ($max = $#$_) foreach @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 512 | ## no critic (BuiltinFunctions::ProhibitComplexMappings) | ||||||||||||||||||||||||||||||||||||||||||||||
| 513 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 25 | my $ix = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 515 | ## no critic (BuiltinFunctions::RequireBlockMap) | ||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 1834 | map $_->[$ix], @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 517 | } 0 .. $max; | ||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||
| 520 | sub zip6 (\@\@;\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 521 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 6 | ▶ | my $max = -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
zip6: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 6 | ▶ | $max < $#$_ && ($max = $#$_) foreach @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 524 | ## no critic (BuiltinFunctions::ProhibitComplexMappings) | ||||||||||||||||||||||||||||||||||||||||||||||
| 525 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 5 | my $ix = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 527 | ## no critic (BuiltinFunctions::RequireBlockMap) | ||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 27 | [map $_->[$ix], @_]; | |||||||||||||||||||||||||||||||||||||||||||||
| 529 | } 0 .. $max; | ||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||
| 532 | sub listcmp (\@\@;\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 533 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 10 | ▶ | my %ret; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listcmp: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 10 | ▶ | for (my $i = 0; $i < scalar @_; ++$i) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 536 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 21 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||
| 538 | my $k; | ||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 21 | ▶ | foreach my $w (grep { defined $_ and not $seen{$k = $_}++ } @{$_[$i]}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 540 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 102 | ▶ | $ret{$w} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$ret{$w} ||= []
MC/DC100%1/1
$ret{$w} ||= []
$ret{$w}
Truth table100%2/2
A
A= $ret{$w}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 102 | push @{$ret{$w}}, $i; | |||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 4 | return %ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||
| 548 | sub uniq (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 549 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 20 | ▶ | my %seen = (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uniq: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 20 | my $k; | |||||||||||||||||||||||||||||||||||||||||||||
| 552 | my $seen_undef; | ||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 20 | ▶ | return grep { defined $_ ? not $seen{$k = $_}++ : not $seen_undef++ } @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||
| 556 | sub singleton (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 557 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 19 | ▶ | my %seen = (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
singleton: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 19 | my $k; | |||||||||||||||||||||||||||||||||||||||||||||
| 560 | my $seen_undef; | ||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 25535 | ▶ | return grep { 1 == (defined $_ ? $seen{$k = $_} : $seen_undef) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 19 | ▶ | grep { defined $_ ? not $seen{$k = $_}++ : not $seen_undef++ } @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||
| 565 | sub duplicates (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 566 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 19 | ▶ | my %seen = (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
duplicates: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 19 | my $k; | |||||||||||||||||||||||||||||||||||||||||||||
| 569 | my $seen_undef; | ||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 24659 | ▶ | return grep { 1 < (defined $_ ? $seen{$k = $_} : $seen_undef) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 19 | ▶ | grep { defined $_ ? not $seen{$k = $_}++ : not $seen_undef++ } @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||
| 574 | sub frequency (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 575 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 17 | ▶ | my %seen = (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
frequency: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 17 | my $k; | |||||||||||||||||||||||||||||||||||||||||||||
| 578 | my $seen_undef; | ||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 25525 | ▶ | my %h = map { defined $_ ? ($_ => $seen{$k = $_}) : () } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 17 | ▶ | grep { defined $_ ? not $seen{$k = $_}++ : not $seen_undef++ } @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 13 | ▶ | wantarray or return (scalar keys %h) + ($seen_undef ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 7 | undef $k; | |||||||||||||||||||||||||||||||||||||||||||||
| 583 | 7 | ▶ | return (%h, $seen_undef ? (\$k => $seen_undef) : ()); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||
| 586 | sub occurrences (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 587 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 12 | ▶ | my %seen = (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
occurrences: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 12 | my $k; | |||||||||||||||||||||||||||||||||||||||||||||
| 590 | my $seen_undef; | ||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 12 | my @ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 592 | 12 | ▶ | foreach my $l (map { $_ } grep { defined $_ ? not $seen{$k = $_}++ : not $seen_undef++ } @_) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 593 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 119 | ▶ | my $n = defined $l ? $seen{$l} : $seen_undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 119 | ▶ | defined $ret[$n] or $ret[$n] = []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 119 | push @{$ret[$n]}, $l; | |||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 8 | return @ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||
| 601 | sub mode (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 602 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 32 | ▶ | my %seen = (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mode: called CC=9 SCAR=24.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 32 | my ($max, $k, $seen_undef) = (1); | |||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 32 | ▶ | foreach (@_) { defined $_ ? ($max < ++$seen{$k = $_} and ++$max) : ($max < ++$seen_undef and ++$max) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$max < ++$seen{$k = $_} and ++$max
$max < ++$seen_undef and ++$max
MC/DC0%0/2
$max < ++$seen{$k = $_} and ++$max
$max < ++$seen{$k = $_}
++$max
MC/DC0%0/2
$max < ++$seen_undef and ++$max
$max < ++$seen_undef
++$max
Truth table66%2/3
A and B
A= $max < ++$seen{$k = $_}B= ++$max
Truth table0%0/3
A and B
A= $max < ++$seen_undefB= ++$max
| |||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 20 | ▶ | wantarray or return $max; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 10 | my @ret = ($max); | |||||||||||||||||||||||||||||||||||||||||||||
| 610 | 10 | foreach my $l (grep { $seen{$_} == $max } keys %seen) | |||||||||||||||||||||||||||||||||||||||||||||
| 611 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 18 | push @ret, $l; | |||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 10 | ▶ | $seen_undef and $seen_undef == $max and push @ret, undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$seen_undef and $seen_undef == $max
MC/DC0%0/2
$seen_undef and $seen_undef == $max
$seen_undef
$seen_undef == $max
Truth table33%1/3
A and B
A= $seen_undefB= $seen_undef == $max
| |||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 10 | return @ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||
| 618 | sub samples ($@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 619 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 4 | ▶ | my $n = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
samples: called CC=3 SCAR=12.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 4 | ▶ | if ($n > @_) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 622 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 1 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||
| 624 | 1 | Carp::croak(sprintf("Cannot get %d samples from %d elements", $n, scalar @_)); | |||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 3 | ▶ | for (my $i = @_; @_ - $i > $n;) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 628 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | my $idx = @_ - $i; | |||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | my $swp = $idx + int(rand(--$i)); | |||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | my $xchg = $_[$swp]; | |||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | $_[$swp] = $_[$idx]; | |||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | $_[$idx] = $xchg; | |||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 3 | return splice @_, 0, $n; | |||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||
| 639 | sub minmax (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 640 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 31 | ▶ | return unless @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
minmax: called CC=14 SCAR=26.5
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 31 | my $min = my $max = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 31 | ▶ | for (my $i = 1; $i < @_; $i += 2) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 645 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 10047 | ▶ | if ($_[$i - 1] <= $_[$i]) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 647 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 28 | ▶ | $min = $_[$i - 1] if $min > $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 28 | ▶ | $max = $_[$i] if $max < $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 651 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 652 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 10019 | ▶ | $min = $_[$i] if $min > $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 10019 | ▶ | $max = $_[$i - 1] if $max < $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 31 | ▶ | if (@_ & 1) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 659 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 25 | my $i = $#_; | |||||||||||||||||||||||||||||||||||||||||||||
| 661 | 25 | ▶ | if ($_[$i - 1] <= $_[$i]) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 662 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 22 | ▶ | $min = $_[$i - 1] if $min > $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 22 | ▶ | $max = $_[$i] if $max < $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 666 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 667 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 3 | ▶ | $min = $_[$i] if $min > $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 3 | ▶ | $max = $_[$i - 1] if $max < $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 31 | return ($min, $max); | |||||||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||
| 676 | sub minmaxstr (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 677 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 25 | ▶ | return unless @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
minmaxstr: called CC=14 SCAR=29.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 25 | my $min = my $max = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 25 | ▶ | for (my $i = 1; $i < @_; $i += 2) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 682 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 1352 | ▶ | if ($_[$i - 1] le $_[$i]) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 684 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | $min = $_[$i - 1] if $min gt $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | $max = $_[$i] if $max lt $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 688 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 689 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 1352 | ▶ | $min = $_[$i] if $min gt $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 1352 | ▶ | $max = $_[$i - 1] if $max lt $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 25 | ▶ | if (@_ & 1) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 696 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 24 | my $i = $#_; | |||||||||||||||||||||||||||||||||||||||||||||
| 698 | 24 | ▶ | if ($_[$i - 1] le $_[$i]) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 699 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 22 | ▶ | $min = $_[$i - 1] if $min gt $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 22 | ▶ | $max = $_[$i] if $max lt $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 703 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 704 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 2 | ▶ | $min = $_[$i] if $min gt $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 2 | ▶ | $max = $_[$i - 1] if $max lt $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 25 | return ($min, $max); | |||||||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||
| 713 | sub part (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 714 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 13 | ▶ | my ($code, @list) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
part: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 13 | my @parts; | |||||||||||||||||||||||||||||||||||||||||||||
| 717 | 13 | push @{$parts[$code->($_)]}, $_ foreach @list; | |||||||||||||||||||||||||||||||||||||||||||||
| 718 | 12 | return @parts; | |||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||
| 721 | sub bsearch(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 722 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 2029 | ▶ | my $code = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bsearch: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 2029 | my $rc; | |||||||||||||||||||||||||||||||||||||||||||||
| 726 | 2029 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 727 | 2029 | my $j = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 728 | ## no critic (ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions) | ||||||||||||||||||||||||||||||||||||||||||||||
| 729 | do | ||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 2029 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 18242 | my $k = int(($i + $j) / 2); | |||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 18242 | ▶ | $k >= @_ and return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 18231 | local *_ = \$_[$k]; | |||||||||||||||||||||||||||||||||||||||||||||
| 736 | 18231 | $rc = $code->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 18228 | ▶ | $rc == 0 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 739 | and return wantarray ? $_ : 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 16224 | ▶ | if ($rc < 0) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 742 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 8214 | $i = $k + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 745 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 746 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 8010 | $j = $k - 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 749 | } until $i > $j; | ||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 11 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||
| 754 | sub bsearchidx(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 755 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 1029 | ▶ | my $code = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bsearchidx: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 1029 | my $rc; | |||||||||||||||||||||||||||||||||||||||||||||
| 759 | 1029 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 760 | 1029 | my $j = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 761 | ## no critic (ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions) | ||||||||||||||||||||||||||||||||||||||||||||||
| 762 | do | ||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 1029 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 9253 | my $k = int(($i + $j) / 2); | |||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 9253 | ▶ | $k >= @_ and return -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 9242 | local *_ = \$_[$k]; | |||||||||||||||||||||||||||||||||||||||||||||
| 769 | 9242 | $rc = $code->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 9239 | ▶ | $rc == 0 and return $k; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 8235 | ▶ | if ($rc < 0) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 774 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 4167 | $i = $k + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 777 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 778 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 4068 | $j = $k - 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } until $i > $j; | ||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 11 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||
| 786 | sub lower_bound(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 787 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 2475 | ▶ | my $code = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lower_bound: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 2475 | my $count = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 790 | 2475 | my $first = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 791 | 2475 | ▶ | while ($count > 0) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 792 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 17856 | my $step = $count >> 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 794 | 17856 | my $it = $first + $step; | |||||||||||||||||||||||||||||||||||||||||||||
| 795 | 17856 | local *_ = \$_[$it]; | |||||||||||||||||||||||||||||||||||||||||||||
| 796 | 17856 | ▶ | if ($code->() < 0) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 797 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 8837 | $first = ++$it; | |||||||||||||||||||||||||||||||||||||||||||||
| 799 | 8837 | $count -= $step + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 801 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 802 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 9009 | $count = $step; | |||||||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 2465 | return $first; | |||||||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||
| 810 | sub upper_bound(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 811 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 243 | ▶ | my $code = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upper_bound: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 243 | my $count = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 814 | 243 | my $first = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 815 | 243 | ▶ | while ($count > 0) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 816 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 1606 | my $step = $count >> 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 818 | 1606 | my $it = $first + $step; | |||||||||||||||||||||||||||||||||||||||||||||
| 819 | 1606 | local *_ = \$_[$it]; | |||||||||||||||||||||||||||||||||||||||||||||
| 820 | 1606 | ▶ | if ($code->() <= 0) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 821 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 768 | $first = ++$it; | |||||||||||||||||||||||||||||||||||||||||||||
| 823 | 768 | $count -= $step + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 825 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 826 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 837 | $count = $step; | |||||||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 242 | return $first; | |||||||||||||||||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||
| 834 | sub equal_range(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 835 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 12 | ▶ | my $lb = &lower_bound(@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
equal_range: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 9 | my $ub = &upper_bound(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 838 | 9 | return ($lb, $ub); | |||||||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||||||
| 841 | sub binsert (&$\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 842 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 1811 | ▶ | my $lb = &lower_bound($_[0], @{$_[2]}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
binsert: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 1810 | splice @{$_[2]}, $lb, 0, $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 845 | 1810 | return $lb; | |||||||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||
| 848 | sub bremove (&\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 849 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 420 | ▶ | my $lb = &lower_bound($_[0], @{$_[1]}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bremove: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 413 | return splice @{$_[1]}, $lb, 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||
| 854 | sub qsort(&\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 855 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | ▶ | require Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
qsort: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | Carp::croak("It's insane to use a pure-perl qsort"); | |||||||||||||||||||||||||||||||||||||||||||||
| 858 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||||||
| 860 | sub slide(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 861 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 2 | ▶ | my $op = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
slide: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 2 | my @l = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||
| 865 | ## no critic (TestingAndDebugging::ProhibitNoStrict, ValuesAndExpressions::ProhibitCommaSeparatedStatements) | ||||||||||||||||||||||||||||||||||||||||||||||
| 866 | # Localise $a, $b | ||||||||||||||||||||||||||||||||||||||||||||||
| 867 | my ($caller_a, $caller_b) = do | ||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 2 | { | |||||||||||||||||||||||||||||||||||||||||||||
| 869 | 2 | my $pkg = caller(); | |||||||||||||||||||||||||||||||||||||||||||||
| 870 | 122 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 2 | \*{$pkg . '::a'}, \*{$pkg . '::b'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 872 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||
| 874 | ## no critic (Variables::RequireInitializationForLocalVars) | ||||||||||||||||||||||||||||||||||||||||||||||
| 875 | # This map expression is also the return value | ||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 2 | local (*$caller_a, *$caller_b); | |||||||||||||||||||||||||||||||||||||||||||||
| 877 | ## no critic (BuiltinFunctions::ProhibitComplexMappings) | ||||||||||||||||||||||||||||||||||||||||||||||
| 878 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 879 | # Assign to $a, $b as refs to caller's array elements | ||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 2 | (*$caller_a, *$caller_b) = \($l[$_], $l[$_ + 1]); | |||||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||||||
| 882 | # Perform the transformation | ||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 4 | $op->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 884 | } 0 .. ($#l - 1); | ||||||||||||||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||
| 887 | sub slideatatime ($$@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 888 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 10 | ▶ | my ($m, $w, @list) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
slideatatime: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 10 | my $n = $w - $m - 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 891 | return $n >= 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 37 | ▶ | ? sub { my @r = splice @list, 0, $m; $#list < $n and $n = $#list; @r and push @r, (@list ? @list[0 .. $n] : ()); return @r; } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 10 | ▶ | : sub { return splice @list, 0, $m; }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 894 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||||||
| 896 | sub sort_by(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 897 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | my ($code, @list) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sort_by: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | return map { $_->[0] } | |||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | sort { $a->[1] cmp $b->[1] } | |||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | map { [$_, scalar($code->())] } @list; | |||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||
| 904 | sub nsort_by(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 905 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ▶ | my ($code, @list) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nsort_by: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | return map { $_->[0] } | |||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | sort { $a->[1] <=> $b->[1] } | |||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | map { [$_, scalar($code->())] } @list; | |||||||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||||||
| 912 | ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 1 | ▶ | sub _XScompiled { return 0 } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_XScompiled: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||||||
| 915 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||||||
| 917 | L<List::Util> | ||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||
| 919 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||
| 921 | Jens Rehsack E<lt>rehsack AT cpan.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||
| 923 | Adam Kennedy E<lt>adamk@cpan.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||||||
| 925 | Tassilo von Parseval E<lt>tassilo.von.parseval@rwth-aachen.deE<gt> | ||||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||
| 927 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||
| 929 | Some parts copyright 2011 Aaron Crane. | ||||||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||||||
| 931 | Copyright 2004 - 2010 by Tassilo von Parseval | ||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||
| 933 | Copyright 2013 - 2017 by Jens Rehsack | ||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||
| 935 | All code added with 0.417 or later is licensed under the Apache License, | ||||||||||||||||||||||||||||||||||||||||||||||
| 936 | Version 2.0 (the "License"); you may not use this file except in compliance | ||||||||||||||||||||||||||||||||||||||||||||||
| 937 | with the License. You may obtain a copy of the License at | ||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||
| 939 | http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||||||
| 941 | Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||||||||||||||||||||
| 942 | distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||||||||||||||||||||
| 943 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||||||||||||||||||||
| 944 | See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||||||||||||||||||||
| 945 | limitations under the License. | ||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||
| 947 | All code until 0.416 is licensed under the same terms as Perl itself, | ||||||||||||||||||||||||||||||||||||||||||||||
| 948 | either Perl version 5.8.4 or, at your option, any later version of | ||||||||||||||||||||||||||||||||||||||||||||||
| 949 | Perl 5 you may have available. | ||||||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||||||
| 951 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 122 | 1; | |||||||||||||||||||||||||||||||||||||||||||||