| 1 | # | ||||||||||||||||||||||||||||||||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | package Rex::Helper::Array; | ||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 105 | ▶ | use v5.14.4; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 105 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 105 | our $VERSION = '1.16.1'; # VERSION | |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 105 | require Exporter; | |||||||||||||||||||||||||||||||
| 13 | 105 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | 105 | ▶ | use vars qw(@EXPORT); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | 105 | @EXPORT = qw(array_uniq in_array); | |||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub array_uniq { | ||||||||||||||||||||||||||||||
|
Subroutine
array_uniq: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 19 | 0 | my (@array) = @_; | |||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 0 | my %all = (); | |||||||||||||||||||||||||||||||
| 22 | 0 | @all{@array} = 1; | |||||||||||||||||||||||||||||||
| 23 | 0 | return keys %all; | |||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub in_array { | ||||||||||||||||||||||||||||||
|
Subroutine
in_array: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 27 | 0 | my ( $needle, @haystack ) = @_; | |||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | my ($ret) = grep { | ||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | if ( ref $needle eq "RegExp" && $_ =~ $needle ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $needle eq "RegExp" and $_ =~ /$needle/u
MC/DC0%0/2
ref $needle eq "RegExp" and $_ =~ /$needle/u
ref $needle eq "RegExp"
$_ =~ /$needle/u
Truth table0%0/3
A and B
A= ref $needle eq "RegExp"B= $_ =~ /$needle/u
| |||||||||||||||||||||||||||||||||
| 31 | 0 | return $_; | |||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||
| 33 | elsif ( $_ eq $needle ) { | ||||||||||||||||||||||||||||||||
| 34 | 0 | return $_; | |||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||
| 36 | } @haystack; | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 0 | return $ret; | |||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 105 | 1; | |||||||||||||||||||||||||||||||