blib/lib/Sub/Recursive.pm

filter: Statementstmt 100% 42 / 42 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 100% 53 / 53 CC 2 SCAR 1.8
CC
2
Cov
100%
mutually_recursive
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 package Sub::Recursive;
2 3 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 3 $VERSION = 0.05;
5 3 @EXPORT = qw/ recursive $REC /;
6 3 @EXPORT_OK = (@EXPORT, qw/ mutually_recursive %REC /);
7 3 $EXPORT_TAGS{ALL} = \@EXPORT_OK;
8  
9 3 $REC = '$REC is a special variable used by ' . __PACKAGE__;
10 3 %REC = ($REC, $REC);
11  
12 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 4 ▶sub recursive (&) {
Subroutine recursive: called CC=1 SCAR=0.0
Pod documented
16 4 my ($code) = @_;
17  
18 3 ▶ my $rec = do { no strict 'refs'; \*{caller() . '::REC'} };
Subroutine BEGIN: called CC=1 SCAR=0.0
19 3 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
20 3 local *$rec = \$code;
21 3 &$code;
22 4 };
23 }
24  
25 1 ▶sub mutually_recursive {
Subroutine mutually_recursive: called CC=2 SCAR=6.9
Pod documented
26 1 my @p = @_;
27 1 my %p = @_;
28  
29 3 ▶ my $rec = do { no strict 'refs'; \*{caller() . '::REC'} };
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 1 my $c = 0;
32 1 my @codes;
33 1 for my $code (grep { $c++ % 2 } @p) {
34 20 ▶ push @codes => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
35 20 local *$rec = \$code;
36 20 local *$rec = \%p;
37 20 &$code;
38 2 };
39 }
40 1 return @codes;
41 }
42  
43 3 1;
44  
45 __END__
↑ Summary