| 1 | # vi: set ts=4 sw=4 ht=4 et : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | package perl5i::2::ARRAY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 109 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 109 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 109 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 109 | ▶ | no if $] >= 5.018000, warnings => 'experimental::smartmatch'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # Don't accidentally turn carp/croak into methods. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 76 | require Carp::Fix::1_25; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 109 | ▶ | use perl5i::2::Signatures; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 109 | ▶ | use perl5i::2::autobox; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # A foreach which honors the number of parameters in the signature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 109 | ▶ | method foreach($code) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
Subroutine
foreach: not called CC=4 SCAR=28.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | my $n = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | if( my $sig = $code->signature ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | $n = $sig->num_positional_params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | Carp::Fix::1_25::croak("Function passed to foreach takes no arguments") unless $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my $idx = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | while ( $idx <= $#{$self} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | $code->(@{$self}[$idx..($idx+$n-1)]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | $idx += $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 76 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 109 | ▶ | method first($filter) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
Subroutine
first: not called CC=2 SCAR=12.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # Deep recursion and segfault (lines 90 and 91 in first.t) if we use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # the same elegant approach as in grep(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if ( ref $filter eq 'Regexp' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | return List::Util::first( sub { $_ ~~ $filter }, @$self ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | return List::Util::first( sub { $filter->() }, @$self ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 76 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 109 | ▶ | method map( $code ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
Subroutine
map: not called CC=2 SCAR=15.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my @result = CORE::map { $code->($_) } @$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | return wantarray ? @result : \@result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 76 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 109 | ▶ | method as_hash{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
Subroutine
__ANON__: not called CC=2 SCAR=15.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my %result = CORE::map { $_ => 1 } @$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | return wantarray ? %result : \%result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 76 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 109 | ▶ | method pick ( $num ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.6
Subroutine
__ANON__: not called CC=10 SCAR=35.2
Subroutine
pick: called CC=10 SCAR=35.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | Carp::Fix::1_25::croak("pick() takes the number of elements to pick") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | unless defined $num; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | Carp::Fix::1_25::croak("pick() takes a positive integer or zero, not '$num'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/12
$num->is_integer and $num->is_positive || $num == 0
$num->is_positive or $num == 0
$num->is_integer and $num->is_positive || $num == 0
$num->is_positive or $num == 0
MC/DC0%0/3
$num->is_integer and $num->is_positive || $num == 0
$num->is_integer
$num->is_positive
$num == 0
MC/DC0%0/3
$num->is_integer and $num->is_positive || $num == 0
$num->is_integer
$num->is_positive
$num == 0
Truth table0%0/4
A and B or C
A= $num->is_integerB= $num->is_positiveC= $num == 0
Truth table0%0/4
A and B or C
A= $num->is_integerB= $num->is_positiveC= $num == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | unless $num->is_integer && ($num->is_positive or $num == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if($num >= @$self){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my @result = List::Util::shuffle(@$self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | return wantarray ? @result : \@result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # for the first position in the array, generate a random number that gives | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # that element an n/N chance of being picked (where n is the number of elements to pick and N is the total array size); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # repeat for the rest of the array, each time altering the probability of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # the element being picked to reflect the number of elements picked so far and the number left. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $num_left = @$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $i=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | while($num > 0){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my $rand = int(rand($num_left)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if($rand < $num){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | push(@result, $self->[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $num--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $num_left--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # Don't return the picks in the same order as the original array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # Simulates what would happen if you shuffled first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | @result = @result->shuffle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | return wantarray ? @result : \@result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 76 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 109 | ▶ | method pick_one() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
Subroutine
pick_one: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | return @$self[int rand @$self]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 76 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 109 | ▶ | method grep($filter) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
grep: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 14 | my @result = CORE::grep { $_ ~~ $filter } @$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 14 | ▶ | return wantarray ? @result : \@result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 76 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 109 | ▶ | method popn($times) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
popn: called CC=7 SCAR=19.5
Subroutine
__ANON__: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 7 | ▶ | Carp::Fix::1_25::croak("popn() takes the number of elements to pop") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | unless defined $times; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 6 | ▶ | Carp::Fix::1_25::croak("popn() takes a positive integer or zero, not '$times'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$times->is_integer and $times->is_positive || $times == 0
$times->is_positive or $times == 0
MC/DC66%2/3
$times->is_integer and $times->is_positive || $times == 0
$times->is_integer
$times->is_positive
$times == 0
Truth table75%3/4
A and B or C
A= $times->is_integerB= $times->is_positiveC= $times == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | unless $times->is_integer && ($times->is_positive or $times == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # splice() will choke if you walk off the array, so rein it in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 4 | ▶ | $times = scalar(@$self) if ($times > scalar(@$self)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 4 | my @result = splice(@$self, -$times, $times); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 4 | ▶ | return wantarray ? @result : \@result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 76 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 109 | ▶ | method shiftn($times) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
shiftn: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 7 | ▶ | Carp::Fix::1_25::croak("shiftn() takes the number of elements to shift") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | unless defined $times; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 6 | ▶ | Carp::Fix::1_25::croak("shiftn() takes a positive integer or zero, not '$times'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$times->is_integer and $times->is_positive || $times == 0
$times->is_positive or $times == 0
MC/DC66%2/3
$times->is_integer and $times->is_positive || $times == 0
$times->is_integer
$times->is_positive
$times == 0
Truth table75%3/4
A and B or C
A= $times->is_integerB= $times->is_positiveC= $times == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | unless $times->is_integer && ($times->is_positive or $times == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # splice() will choke if you walk off the array, so rein it in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 4 | ▶ | $times = scalar(@$self) if ($times > scalar(@$self)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 4 | my @result = splice(@$self, 0, $times); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 4 | ▶ | return wantarray ? @result : \@result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 76 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | sub all { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 2 | ▶ | require List::MoreUtils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | return &List::MoreUtils::all($_[1], @{$_[0]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | sub any { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | ▶ | require List::MoreUtils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | return &List::MoreUtils::any($_[1], @{$_[0]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | sub none { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | ▶ | require List::MoreUtils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
none: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | return &List::MoreUtils::none($_[1], @{$_[0]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | sub true { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | ▶ | require List::MoreUtils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
true: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | return &List::MoreUtils::true($_[1], @{$_[0]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | sub false { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | ▶ | require List::MoreUtils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
false: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 2 | return &List::MoreUtils::false($_[1], @{$_[0]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | sub uniq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 4 | ▶ | require List::MoreUtils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uniq: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 4 | my @uniq = List::MoreUtils::uniq(@{$_[0]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 4 | ▶ | return wantarray ? @uniq : \@uniq; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | sub minmax { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 3 | ▶ | require List::MoreUtils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
minmax: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 3 | my @minmax = List::MoreUtils::minmax(@{$_[0]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 3 | ▶ | return wantarray ? @minmax : \@minmax; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | sub mesh { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | ▶ | require List::MoreUtils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mesh: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 3 | my @mesh = &List::MoreUtils::zip(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 3 | ▶ | return wantarray ? @mesh : \@mesh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # Compare differences between two arrays. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 21 | ▶ | my $diff_two_deeply = func($c, $d) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 21 | my $diff = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # For each element of $c, try to find if it is equal to any of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # elements of $d. If not, it's unique, and has to be pushed into | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # $diff. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 21 | require perl5i::2::equal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 21 | require List::MoreUtils; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 21 | foreach my $item (@$c) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 47 | ▶ | unless ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 93 | ▶ | List::MoreUtils::any( sub { perl5i::2::equal::are_equal( $item, $_ ) }, @$d ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 21 | push @$diff, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 21 | return $diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 76 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 16 | ▶ | my $diff_two_simply = func($c, $d) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 109 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 16 | my %seen = map { $_ => 1 } @$d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 16 | my @diff = grep { not $seen{$_} } @$c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 16 | return \@diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 76 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 109 | ▶ | method diff(@rest) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
Subroutine
diff: not called CC=7 SCAR=38.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | unless (@rest) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | return wantarray ? @$self : $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | require List::MoreUtils; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | my $has_refs = List::MoreUtils::any(sub { ref $_ }, @$self); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | my $diff_two = $has_refs ? $diff_two_deeply : $diff_two_simply; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # XXX If I use carp here, the exception is "bizarre copy of ARRAY in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # ssasign ... " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | die "Arguments must be array references" if grep { ref $_ ne 'ARRAY' } @rest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | foreach my $array (@rest) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $self = $diff_two->($self, $array); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | return wantarray ? @$self : $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 76 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 16 | ▶ | my $intersect_two_simply = func($c, $d) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 109 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 16 | my %seen = map { $_ => 1 } @$d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 16 | my @intersect = grep { $seen{$_} } @$c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 16 | return \@intersect; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 76 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | # Compare differences between two arrays. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 14 | ▶ | my $intersect_two_deeply = func($c, $d) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 14 | require perl5i::2::equal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 14 | my $intersect = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # For each element of $c, try to find if it is equal to any of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # elements of $d. If it is, it's shared, and has to be pushed into | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | # $intersect. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 14 | require List::MoreUtils; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 14 | foreach my $item (@$c) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 33 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 80 | ▶ | List::MoreUtils::any( sub { perl5i::2::equal::are_equal( $item, $_ ) }, @$d ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 20 | push @$intersect, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 14 | return $intersect; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 76 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 109 | ▶ | method intersect(@rest) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
intersect: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 33 | ▶ | unless (@rest) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | ▶ | return wantarray ? @$self : $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 32 | require List::MoreUtils; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 32 | ▶ | my $has_refs = List::MoreUtils::any(sub { ref $_ }, @$self); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 32 | ▶ | my $intersect_two = $has_refs ? $intersect_two_deeply : $intersect_two_simply; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # XXX If I use carp here, the exception is "bizarre copy of ARRAY in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | # ssasign ... " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 32 | ▶ | die "Arguments must be array references" if grep { ref $_ ne 'ARRAY' } @rest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 28 | foreach my $array (@rest) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 30 | $self = $intersect_two->($self, $array); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 28 | ▶ | return wantarray ? @$self : $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 76 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 109 | ▶ | method ltrim($charset) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 4 | my @result = CORE::map { $_->ltrim($charset) } @$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 4 | ▶ | return wantarray ? @result : \@result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 76 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 109 | ▶ | method rtrim($charset) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
rtrim: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 4 | my @result = CORE::map { $_->rtrim($charset) } @$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 4 | ▶ | return wantarray ? @result : \@result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 76 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 109 | ▶ | method trim($charset) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
trim: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 5 | my @result = CORE::map { $_->trim($charset) } @$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 5 | ▶ | return wantarray ? @result : \@result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 76 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 76 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||