| 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
| |||||||||||
| 7 | 0 | ▶ | unless (@_ >= 2) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 8 | 0 | ▶ | my $type = ($method eq 'import') ? 'use' : 'no'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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__ | ||||||||||