line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## no critic: () |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package PerlX::ifor; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $DATE = '2019-04-16'; # DATE |
6
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
56590
|
use strict; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
26
|
|
9
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use Exporter qw(import); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
113
|
|
12
|
|
|
|
|
|
|
our @EXPORT = qw(ifor); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub ifor(&$) { |
15
|
1
|
|
|
1
|
0
|
110
|
my ($code, $iterator) = @_; |
16
|
|
|
|
|
|
|
|
17
|
1
|
50
|
|
|
|
5
|
if (ref $iterator eq 'CODE') { |
18
|
1
|
|
|
|
|
2
|
local $_; |
19
|
1
|
|
|
|
|
3
|
while (defined($_ = $iterator->())) { |
20
|
10
|
|
|
|
|
65
|
$code->(); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} else { |
23
|
0
|
|
|
|
|
|
die "Only coderef iterator is supported at the moment"; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
# ABSTRACT: A version of for() that accepts iterator instead of list |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__END__ |