| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
2
|
|
|
2
|
|
1491
|
use 5.008; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
75
|
|
|
2
|
2
|
|
|
2
|
|
11
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
52
|
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
103
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Loop::Control; |
|
6
|
|
|
|
|
|
|
our $VERSION = '1.100861'; |
|
7
|
|
|
|
|
|
|
# ABSTRACT: FIRST and NEXT functions for loops |
|
8
|
2
|
|
|
2
|
|
2104
|
use Scope::Upper qw(reap :words); |
|
|
2
|
|
|
|
|
2656
|
|
|
|
2
|
|
|
|
|
373
|
|
|
9
|
2
|
|
|
2
|
|
13
|
use Exporter qw(import); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
620
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT = qw(FIRST NEXT); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub callstack_depth { |
|
13
|
0
|
|
|
0
|
1
|
0
|
my $depth = 0; |
|
14
|
0
|
|
|
|
|
0
|
while (caller($depth)) { $depth++ } |
|
|
0
|
|
|
|
|
0
|
|
|
15
|
0
|
|
|
|
|
0
|
$depth; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub FIRST (&) { |
|
19
|
0
|
|
|
0
|
1
|
0
|
my $code = shift; |
|
20
|
0
|
|
|
|
|
0
|
my ($package, $filename, $line) = caller; |
|
21
|
0
|
|
|
|
|
0
|
my $callstack_depth = callstack_depth(); |
|
22
|
0
|
|
|
|
|
0
|
my $key = "FIRST $package $filename $line $callstack_depth"; |
|
23
|
0
|
|
|
|
|
0
|
our %seen; |
|
24
|
0
|
0
|
|
|
|
0
|
unless ($seen{$key}++) { |
|
25
|
0
|
|
|
|
|
0
|
$code->(); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
0
|
|
|
0
|
|
0
|
reap sub { delete $seen{$key} } => UP UP; |
|
|
0
|
|
|
|
|
0
|
|
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub NEXT (&) { |
|
31
|
16
|
|
|
16
|
1
|
319
|
my $code = shift; |
|
32
|
16
|
|
|
16
|
|
117
|
reap sub { $code->() } => UP; |
|
|
16
|
|
|
|
|
113
|
|
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
1; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |