line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package List::Util::Find; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2021-06-10'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'List-Util-Find'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.003'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
73750
|
use strict; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
34
|
|
9
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use Exporter 'import'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
62
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
13
|
|
|
|
|
|
|
hasnum |
14
|
|
|
|
|
|
|
hasstr |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub hasnum { |
18
|
1
|
|
|
1
|
|
7
|
no warnings 'numeric'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
356
|
|
19
|
|
|
|
|
|
|
|
20
|
6
|
|
|
6
|
1
|
1603
|
my $needle = shift; |
21
|
6
|
50
|
|
|
|
17
|
warn "hasnum(): needle is undefined" unless defined $needle; |
22
|
|
|
|
|
|
|
|
23
|
6
|
|
|
|
|
12
|
for (@_) { |
24
|
|
|
|
|
|
|
# TODO: handle Inf & -Inf (and NaN also?) |
25
|
45
|
100
|
|
|
|
71
|
next unless defined; |
26
|
41
|
100
|
|
|
|
87
|
next unless $needle == $_; |
27
|
10
|
100
|
|
|
|
22
|
if ($needle == 0) { |
28
|
|
|
|
|
|
|
# when needle == 0, we want to make sure that we don't match "foo" |
29
|
|
|
|
|
|
|
# as 0. |
30
|
7
|
100
|
|
|
|
30
|
return 1 if /\A\s*[+-]?(?:0|[1-9][0-9]*)\s*\z/s; # from isint() |
31
|
6
|
50
|
33
|
|
|
49
|
return 1 if /\A\s*[+-]? |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
32
|
|
|
|
|
|
|
(?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) |
33
|
|
|
|
|
|
|
([eE][+-]?[0-9]+)?\s*\z/sx && $1 || $2 || $3; # from isfloat() |
34
|
6
|
|
|
|
|
12
|
next; |
35
|
|
|
|
|
|
|
} else { |
36
|
3
|
|
|
|
|
15
|
return 1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
2
|
|
|
|
|
10
|
0; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub hasstr { |
43
|
5
|
|
|
5
|
1
|
2698
|
my $needle = shift; |
44
|
|
|
|
|
|
|
|
45
|
5
|
50
|
|
|
|
16
|
warn "hasstr(): needle is undefined" unless defined $needle; |
46
|
|
|
|
|
|
|
|
47
|
5
|
|
|
|
|
10
|
for (@_) { |
48
|
32
|
100
|
100
|
|
|
122
|
return 1 if defined $_ && $needle eq $_; |
49
|
|
|
|
|
|
|
} |
50
|
2
|
|
|
|
|
8
|
0; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
# ABSTRACT: List utilities related to finding items |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |