line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Array::Iter; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2021-07-25'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'Array-Iter'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.021'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
502
|
use strict; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
29
|
|
9
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use Exporter qw(import); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
179
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw(array_iter list_iter); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub array_iter { |
15
|
2
|
|
|
2
|
1
|
1192
|
my $ary = shift; |
16
|
2
|
|
|
|
|
4
|
my $i = 0; |
17
|
|
|
|
|
|
|
sub { |
18
|
12
|
100
|
|
12
|
|
45
|
if ($i < @$ary) { |
19
|
10
|
|
|
|
|
21
|
return $ary->[$i++]; |
20
|
|
|
|
|
|
|
} else { |
21
|
2
|
|
|
|
|
5
|
return undef; |
22
|
|
|
|
|
|
|
} |
23
|
2
|
|
|
|
|
12
|
}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub list_iter { |
27
|
1
|
|
|
1
|
1
|
2866
|
array_iter([@_]); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
# ABSTRACT: Generate a coderef iterator for an array |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__END__ |