line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package unless; |
2
|
|
|
|
|
|
|
$unless::VERSION = '0.06'; |
3
|
|
|
|
|
|
|
#ABSTRACT: use a Perl module unless a condition holds |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub work { |
6
|
4
|
50
|
|
4
|
|
13
|
my $method = shift() ? 'import' : 'unimport'; |
7
|
4
|
50
|
|
|
|
12
|
die "Too few arguments to 'use unless' (some code returning an empty list in list context?)" |
8
|
|
|
|
|
|
|
unless @_ >= 2; |
9
|
4
|
100
|
|
|
|
71
|
return if shift; # CONDITION |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
|
|
4
|
my $p = $_[0]; # PACKAGE |
12
|
2
|
|
|
|
|
8
|
(my $file = "$p.pm") =~ s!::!/!g; |
13
|
2
|
|
|
|
|
17
|
require $file; # Works even if $_[0] is a keyword (like open) |
14
|
2
|
|
|
|
|
30
|
my $m = $p->can($method); |
15
|
2
|
50
|
|
|
|
53
|
goto &$m if $m; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
|
6373
|
sub import { shift; unshift @_, 1; goto &work } |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
12
|
|
19
|
0
|
|
|
0
|
|
|
sub unimport { shift; unshift @_, 0; goto &work } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
q"There must be something wrong with human nature"; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__END__ |