File Coverage

inc/if.pm
Criterion Covered Total %
statement 11 16 68.7
branch 4 10 40.0
condition n/a
subroutine 2 3 66.6
pod n/a
total 17 29 58.6


line stmt bran cond sub pod time code
1             #line 1
2             package if;
3              
4             $VERSION = '0.0606';
5              
6 12 50   12   37 sub work {
7 12 50       40 my $method = shift() ? 'import' : 'unimport';
8 0 0       0 unless (@_ >= 2) {
9 0         0 my $type = ($method eq 'import') ? 'use' : 'no';
10             die "Too few arguments to '$type if' (some code returning an empty list in list context?)"
11 12 50       30 }
12             return unless shift; # CONDITION
13 12         19  
14 12         42 my $p = $_[0]; # PACKAGE
15 12         1681 (my $file = "$p.pm") =~ s!::!/!g;
16 12         88 require $file; # Works even if $_[0] is a keyword (like open)
17 12 50       67 my $m = $p->can($method);
18             goto &$m if $m;
19             }
20 12     12   302  
  12         30  
  12         48  
21 0     0     sub import { shift; unshift @_, 1; goto &work }
  0            
  0            
22             sub unimport { shift; unshift @_, 0; goto &work }
23              
24             1;
25             __END__