line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sub::Apply; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
91125
|
use 5.008008; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
175
|
|
4
|
4
|
|
|
4
|
|
22
|
use strict; |
|
4
|
|
|
|
|
24
|
|
|
4
|
|
|
|
|
156
|
|
5
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
141
|
|
6
|
4
|
|
|
4
|
|
3252
|
use parent 'Exporter'; |
|
4
|
|
|
|
|
1240
|
|
|
4
|
|
|
|
|
20
|
|
7
|
4
|
|
|
4
|
|
214
|
use Carp (); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1038
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw(apply apply_if); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $WARNING = 0; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub apply { |
15
|
6
|
|
|
6
|
1
|
3041
|
my $orig = shift; |
16
|
6
|
|
|
|
|
15
|
my $caller = caller; |
17
|
6
|
|
|
|
|
18
|
my $proc = _find_proc( $caller, $orig ); |
18
|
6
|
100
|
|
|
|
528
|
Carp::croak "No such proc $orig" unless $proc; |
19
|
3
|
|
|
|
|
11
|
$proc->(@_); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub apply_if { |
23
|
3
|
|
|
3
|
1
|
2611
|
my $orig = shift; |
24
|
3
|
|
|
|
|
9
|
my $caller = caller; |
25
|
3
|
|
|
|
|
9
|
my $proc = _find_proc( $caller, $orig ); |
26
|
3
|
100
|
|
|
|
9
|
unless ( $proc ) { |
27
|
1
|
50
|
|
|
|
5
|
Carp::carp "No such proc $orig" if $WARNING; |
28
|
1
|
|
|
|
|
3
|
return; |
29
|
|
|
|
|
|
|
} |
30
|
2
|
|
|
|
|
8
|
$proc->(@_); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _find_proc { |
34
|
9
|
|
|
9
|
|
15
|
my ( $caller, $proc ) = @_; |
35
|
9
|
|
|
|
|
63
|
( my $package, $proc ) = $proc =~ m/^(?:(.+)::)?(.+)$/; |
36
|
9
|
|
66
|
|
|
41
|
$package ||= $caller; |
37
|
9
|
|
|
|
|
11
|
my $code = do { |
38
|
4
|
|
|
4
|
|
18
|
no strict 'refs'; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
777
|
|
39
|
9
|
|
|
|
|
12
|
my $stash = \%{ $package . '::' }; |
|
9
|
|
|
|
|
27
|
|
40
|
9
|
100
|
66
|
|
|
115
|
$stash && $stash->{$proc} && *{ $stash->{$proc} }{CODE}; |
|
5
|
|
|
|
|
39
|
|
41
|
|
|
|
|
|
|
}; |
42
|
9
|
|
|
|
|
27
|
return $code; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
__END__ |