line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sub::Recursive; |
2
|
3
|
|
|
3
|
|
63986
|
use 5.006; |
|
3
|
|
|
|
|
14
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
$VERSION = 0.05; |
5
|
|
|
|
|
|
|
@EXPORT = qw/ recursive $REC /; |
6
|
|
|
|
|
|
|
@EXPORT_OK = (@EXPORT, qw/ mutually_recursive %REC /); |
7
|
|
|
|
|
|
|
$EXPORT_TAGS{ALL} = \@EXPORT_OK; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$REC = '$REC is a special variable used by ' . __PACKAGE__; |
10
|
|
|
|
|
|
|
%REC = ($REC, $REC); |
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
19
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
129
|
|
13
|
3
|
|
|
3
|
|
17
|
use base 'Exporter'; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
435
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub recursive (&) { |
16
|
4
|
|
|
4
|
1
|
1015
|
my ($code) = @_; |
17
|
|
|
|
|
|
|
|
18
|
3
|
|
|
3
|
|
20
|
my $rec = do { no strict 'refs'; \*{caller() . '::REC'} }; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
419
|
|
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
18
|
|
19
|
|
|
|
|
|
|
return sub { |
20
|
3
|
|
|
3
|
|
497
|
local *$rec = \$code; |
21
|
3
|
|
|
|
|
8
|
&$code; |
22
|
4
|
|
|
|
|
19
|
}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub mutually_recursive { |
26
|
1
|
|
|
1
|
1
|
20
|
my @p = @_; |
27
|
1
|
|
|
|
|
5
|
my %p = @_; |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
3
|
|
18
|
my $rec = do { no strict 'refs'; \*{caller() . '::REC'} }; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
468
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
9
|
|
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
2
|
my $c = 0; |
32
|
1
|
|
|
|
|
2
|
my @codes; |
33
|
1
|
|
|
|
|
3
|
for my $code (grep { $c++ % 2 } @p) { |
|
4
|
|
|
|
|
8
|
|
34
|
|
|
|
|
|
|
push @codes => sub { |
35
|
20
|
|
|
20
|
|
213
|
local *$rec = \$code; |
36
|
20
|
|
|
|
|
27
|
local *$rec = \%p; |
37
|
20
|
|
|
|
|
28
|
&$code; |
38
|
2
|
|
|
|
|
12
|
}; |
39
|
|
|
|
|
|
|
} |
40
|
1
|
|
|
|
|
5
|
return @codes; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |