line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Array::AllUtils; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2016-04-13'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#IFUNBUILT |
7
|
|
|
|
|
|
|
# use strict 'vars', 'subs'; |
8
|
|
|
|
|
|
|
# use warnings; |
9
|
|
|
|
|
|
|
#END IFUNBUILT |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require Exporter; |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
13
|
|
|
|
|
|
|
first |
14
|
|
|
|
|
|
|
firstidx |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub import { |
18
|
1
|
|
|
1
|
|
5
|
my $pkg = caller; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# (RT88848) Touch the caller's $a and $b, to avoid the warning of |
21
|
|
|
|
|
|
|
# Name "main::a" used only once: possible typo" warning |
22
|
|
|
|
|
|
|
#no strict 'refs'; |
23
|
|
|
|
|
|
|
#${"${pkg}::a"} = ${"${pkg}::a"}; |
24
|
|
|
|
|
|
|
#${"${pkg}::b"} = ${"${pkg}::b"}; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
49
|
goto &Exporter::import; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# BEGIN_BLOCK: first |
30
|
|
|
|
|
|
|
sub first(&$) { |
31
|
2
|
|
|
2
|
1
|
708
|
my $code = shift; |
32
|
2
|
|
|
|
|
2
|
for (@{$_[0]}) { |
|
2
|
|
|
|
|
4
|
|
33
|
5
|
100
|
|
|
|
15
|
return $_ if $code->($_); |
34
|
|
|
|
|
|
|
} |
35
|
1
|
|
|
|
|
5
|
undef; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
# END_BLOCK: first |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# BEGIN_BLOCK: firstidx |
40
|
|
|
|
|
|
|
sub firstidx(&$) { |
41
|
2
|
|
|
2
|
1
|
1196
|
my $code = shift; |
42
|
2
|
|
|
|
|
2
|
my $i = 0; |
43
|
2
|
|
|
|
|
2
|
for (@{$_[0]}) { |
|
2
|
|
|
|
|
5
|
|
44
|
5
|
100
|
|
|
|
7
|
return $i if $code->($_); |
45
|
4
|
|
|
|
|
12
|
$i++; |
46
|
|
|
|
|
|
|
} |
47
|
1
|
|
|
|
|
3
|
-1; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
# END_BLOCK: firstidx |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
# ABSTRACT: Like List::Util & List::MoreUtils but for array(ref) |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |