blib/lib/List/Util/Find.pm

filter: Statementstmt 42.5% 34 / 80 Branchbran 29.5% 13 / 44 Conditioncond 50.0% 6 / 12 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 30.0% 6 / 20 Podpod 100% 16 / 16 totaltotal 43.2% 77 / 178 CC 39 SCAR 25.0
CC
39
Cov
39%
hasanynums
20.0
hasanystrs
20.0
lacksanynums
20.0
CRAP 12.2
↑ Summary
1 package List::Util::Find;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
9 2 our $DATE = '2026-03-29'; # DATE
10 2 our $DIST = 'List-Util-Find'; # DIST
11 2 our $VERSION = '0.005.1'; # VERSION
12  
13 2 our @EXPORT_OK = qw(
14 hasnum
15 hasstr
16 lacksnum
17 lacksstr
18 hasallnums
19 hasanynums
20 hasnonenums
21 hasallstrs
22 hasanystrs
23 hasnonestrs
24 lacksallnums
25 lacksanynums
26 lacksnonenums
27 lacksallstrs
28 lacksanystrs
29 lacksnonestrs
30 );
31  
32 6 ▶sub hasnum {
Subroutine hasnum: called CC=11 SCAR=25.2
Pod documented
33 2 ▶ no warnings 'numeric';
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 6 my $needle = shift;
36 6 ▶ warn "hasnum(): needle is undefined" unless defined $needle;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $needle 0 6 6
37  
38 6 for (@_) {
39 # TODO: handle Inf & -Inf (and NaN also?)
40 45 ▶ next unless defined;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 4 41 45
41 41 ▶ next unless $needle == $_;
Branch: 1 branch
BranchTrueFalseTotal
unless $needle == $_ 31 10 41
42 10 ▶ if ($needle == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($needle == 0) { } 7 3 10
43 # when needle == 0, we want to make sure that we don't match "foo"
44 # as 0.
45 7 ▶ return 1 if /\A\s*[+-]?(?:0|[1-9][0-9]*)\s*\z/s; # from isint()
Branch: 1 branch
BranchTrueFalseTotal
if /\A\s*[+-]?(?:0|[1-9][0-9]*)\s*\z/s 1 6 7
46 6 ▶ return 1 if /\A\s*[+-]?
Branch: 1 branch
BranchTrueFalseTotal
if /\A\s*[+-]? (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) ([eE][+-]?[0-9]+)?\s*\z/sx and $1 or $2 or $3 0 6 6
Condition33%3/9
/\A\s*[+-]? (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) ([eE][+-]?[0-9]+)?\s*\z/sx and $1 or $2 or $3
l!l&&r!l&&!r
006
/\A\s*[+-]? (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) ([eE][+-]?[0-9]+)?\s*\z/sx and $1 or $2
l!l&&r!l&&!r
006
/\A\s*[+-]? (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) ([eE][+-]?[0-9]+)?\s*\z/sx and $1
!ll&&!rl&&r
600
MC/DC0%0/4
/\A\s*[+-]? (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) ([eE][+-]?[0-9]+)?\s*\z/sx and $1 or $2 or $3
/\A\s*[+-]? (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) ([eE][+-]?[0-9]+)?\s*\z/sx $1 $2 $3
Truth table14%1/7
A and B or C or D
A= /\A\s*[+-]? (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) ([eE][+-]?[0-9]+)?\s*\z/sxB= $1C= $2D= $3
ABCDresult
11XX1
0X1X1
101X1
0X011
10011
0X000
10000
47 (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) )
48 ([eE][+-]?[0-9]+)?\s*\z/sx && $1 || $2 || $3; # from isfloat()
49 6 next;
50 } else {
51 3 return 1;
52 }
53 }
54 2 0;
55 }
56  
57 5 ▶sub hasstr {
Subroutine hasstr: called CC=5 SCAR=16.1
Pod documented
58 5 my $needle = shift;
59  
60 5 ▶ warn "hasstr(): needle is undefined" unless defined $needle;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $needle 0 5 5
61  
62 5 for (@_) {
63 32 ▶ return 1 if defined $_ && $needle eq $_;
Branch: 1 branch
BranchTrueFalseTotal
if defined $_ and $needle eq $_ 3 29 32
Condition100%3/3
defined $_ and $needle eq $_
!ll&&!rl&&r
4253
MC/DC100%2/2
defined $_ and $needle eq $_
defined $_ $needle eq $_
Truth table100%3/3
A and B
A= defined $_B= $needle eq $_
ABresult
0X0
100
111
64 }
65 2 0;
66 }
67  
68 0 ▶sub lacksnum {
Subroutine lacksnum: not called CC=1 SCAR=6.9
Pod documented
69 0 my $needle = shift;
70 0 !hasnum($needle, @_);
71 }
72  
73 0 ▶sub lacksstr {
Subroutine lacksstr: not called CC=1 SCAR=6.9
Pod documented
74 0 my $needle = shift;
75 0 !hasstr($needle, @_);
76 }
77  
78 0 ▶sub hasallnums {
Subroutine hasallnums: not called CC=3 SCAR=24.8
Pod documented
79 0 my $needles = shift;
80 0 for my $needle (@$needles) {
81 0 ▶ return 0 if !hasnum($needle, @_);
Branch: 1 branch
BranchTrueFalseTotal
unless hasnum($needle, @_) 0 0 0
82 }
83 0 1;
84 }
85  
86 0 ▶sub hasallstrs {
Subroutine hasallstrs: not called CC=3 SCAR=24.8
Pod documented
87 0 my $needles = shift;
88 0 for my $needle (@$needles) {
89 0 ▶ return 0 if !hasstr($needle, @_);
Branch: 1 branch
BranchTrueFalseTotal
unless hasstr($needle, @_) 0 0 0
90 }
91 0 1;
92 }
93  
94 0 ▶sub hasanynums {
Subroutine hasanynums: not called CC=4 SCAR=30.0
Pod documented
95 0 my $needles = shift;
96 0 for my $needle (@$needles) {
97 0 ▶ return 1 if !hasnum($needle, @_);
Branch: 1 branch
BranchTrueFalseTotal
unless hasnum($needle, @_) 0 0 0
98 }
99 0 ▶ @$needles ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
@$needles ? : 0 0 0
100 }
101  
102 0 ▶sub hasanystrs {
Subroutine hasanystrs: not called CC=4 SCAR=30.0
Pod documented
103 0 my $needles = shift;
104 0 for my $needle (@$needles) {
105 0 ▶ return 1 if !hasstr($needle, @_);
Branch: 1 branch
BranchTrueFalseTotal
unless hasstr($needle, @_) 0 0 0
106 }
107 0 ▶ @$needles ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
@$needles ? : 0 0 0
108 }
109  
110 0 ▶sub hasnonenums {
Subroutine hasnonenums: not called CC=3 SCAR=24.8
Pod documented
111 0 my $needles = shift;
112 0 for my $needle (@$needles) {
113 0 ▶ return 0 if hasnum($needle, @_);
Branch: 1 branch
BranchTrueFalseTotal
if hasnum($needle, @_) 0 0 0
114 }
115 0 1;
116 }
117  
118 0 ▶sub hasnonestrs {
Subroutine hasnonestrs: not called CC=3 SCAR=24.8
Pod documented
119 0 my $needles = shift;
120 0 for my $needle (@$needles) {
121 0 ▶ return 0 if hasstr($needle, @_);
Branch: 1 branch
BranchTrueFalseTotal
if hasstr($needle, @_) 0 0 0
122 }
123 0 1;
124 }
125  
126 0 ▶sub lacksallnums {
Subroutine lacksallnums: not called CC=3 SCAR=24.8
Pod documented
127 0 my $needles = shift;
128 0 for my $needle (@$needles) {
129 0 ▶ return 0 if hasnum($needle, @_);
Branch: 1 branch
BranchTrueFalseTotal
if hasnum($needle, @_) 0 0 0
130 }
131 0 1;
132 }
133  
134 0 ▶sub lacksallstrs {
Subroutine lacksallstrs: not called CC=3 SCAR=24.8
Pod documented
135 0 my $needles = shift;
136 0 for my $needle (@$needles) {
137 0 ▶ return 0 if hasstr($needle, @_);
Branch: 1 branch
BranchTrueFalseTotal
if hasstr($needle, @_) 0 0 0
138 }
139 0 1;
140 }
141  
142 0 ▶sub lacksanynums {
Subroutine lacksanynums: not called CC=4 SCAR=30.0
Pod documented
143 0 my $needles = shift;
144 0 for my $needle (@$needles) {
145 0 ▶ return 1 if !lacksnum($needle, @_);
Branch: 1 branch
BranchTrueFalseTotal
unless lacksnum($needle, @_) 0 0 0
146 }
147 0 ▶ @$needles ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
@$needles ? : 0 0 0
148 }
149  
150 0 ▶sub lacksanystrs {
Subroutine lacksanystrs: not called CC=4 SCAR=30.0
Pod documented
151 0 my $needles = shift;
152 0 for my $needle (@$needles) {
153 0 ▶ return 1 if !lacksstr($needle, @_);
Branch: 1 branch
BranchTrueFalseTotal
unless lacksstr($needle, @_) 0 0 0
154 }
155 0 ▶ @$needles ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
@$needles ? : 0 0 0
156 }
157  
158 0 ▶sub lacksnonenums {
Subroutine lacksnonenums: not called CC=1 SCAR=6.9
Pod documented
159 0 hasallnums(@_);
160 }
161  
162 0 ▶sub lacksnonestrs {
Subroutine lacksnonestrs: not called CC=1 SCAR=6.9
Pod documented
163 0 hasallstrs(@_);
164 }
165  
166 2 1;
167 # ABSTRACT: List utilities related to finding items
168  
169 __END__
↑ Summary