blib/lib/if.pm

filter: Statementstmt 0.0% 0 / 16 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 29 CC 6 SCAR 34.7
CC
6
Cov
0%
work
42.0
import
2.0
unimport
2.0
CRAP 32.0
↑ Summary
1 package if;
2  
3 $VERSION = '0.0608';
4  
5 sub work {
6 0 ▶ my $method = shift() ? 'import' : 'unimport';
Subroutine work: not called CC=6 SCAR=37.4
Branch: 1 branch
BranchTrueFalseTotal
shift() ? : 0 0 0
7 0 ▶ unless (@_ >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@_ >= 2) 0 0 0
8 0 ▶ my $type = ($method eq 'import') ? 'use' : 'no';
Branch: 1 branch
BranchTrueFalseTotal
$method eq 'import' ? : 0 0 0
9 0 die "Too few arguments to '$type if' (some code returning an empty list in list context?)"
10 }
11 0 ▶ return unless shift; # CONDITION
Branch: 1 branch
BranchTrueFalseTotal
unless shift() 0 0 0
12  
13 0 my $p = $_[0]; # PACKAGE
14 0 (my $file = "$p.pm") =~ s!::!/!g;
15 0 require $file; # Works even if $_[0] is a keyword (like open)
16 0 my $m = $p->can($method);
17 0 ▶ goto &$m if $m;
Branch: 1 branch
BranchTrueFalseTotal
if $m 0 0 0
18 }
19  
20 0 ▶sub import { shift; unshift @_, 1; goto &work }
Subroutine import: not called CC=1 SCAR=6.9
21 0 ▶sub unimport { shift; unshift @_, 0; goto &work }
Subroutine unimport: not called CC=1 SCAR=6.9
22  
23 1;
24 __END__
↑ Summary