line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
103748
|
use 5.006; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
239
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Devel::Sub::Which; |
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
25
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
113
|
|
8
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
183
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = "0.05"; |
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
3162
|
use Sub::Identify qw(sub_fullname); |
|
4
|
|
|
|
|
4138
|
|
|
4
|
|
|
|
|
281
|
|
13
|
4
|
|
|
4
|
|
98
|
use Scalar::Util qw/reftype/; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
464
|
|
14
|
4
|
|
|
4
|
|
26
|
use Carp qw/croak/; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
415
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Sub::Exporter -setup => { |
17
|
|
|
|
|
|
|
exports => [qw(which ref_to_name)], |
18
|
|
|
|
|
|
|
collectors => { |
19
|
2
|
|
|
|
|
1482
|
':universal' => sub { *UNIVERSAL::which = \&which; return 1 }, |
|
2
|
|
|
|
|
7
|
|
20
|
|
|
|
|
|
|
} |
21
|
4
|
|
|
4
|
|
21214
|
}; |
|
4
|
|
|
|
|
63620
|
|
|
4
|
|
|
|
|
57
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub which ($;$) { |
24
|
5
|
|
|
5
|
1
|
2926
|
my $obj = shift; |
25
|
5
|
|
|
|
|
10
|
my $sub = shift; |
26
|
|
|
|
|
|
|
|
27
|
5
|
100
|
|
|
|
23
|
return sub_fullname($obj) if not defined $sub; # just a sub, no object |
28
|
|
|
|
|
|
|
|
29
|
4
|
50
|
33
|
|
|
23
|
if (ref($sub) and reftype($sub) eq 'CODE'){ |
30
|
0
|
|
|
|
|
0
|
return sub_fullname($sub); |
31
|
|
|
|
|
|
|
} else { |
32
|
4
|
|
|
|
|
25
|
my $ref = $obj->can($sub); |
33
|
4
|
100
|
66
|
|
|
54
|
croak("$obj\->can($sub) did not return a code reference") |
34
|
|
|
|
|
|
|
unless ref($ref) and reftype($ref) eq 'CODE'; |
35
|
3
|
|
|
|
|
12
|
return sub_fullname($ref); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub ref_to_name ($) { |
40
|
3
|
|
|
3
|
1
|
1726
|
my $sub = shift; |
41
|
|
|
|
|
|
|
|
42
|
3
|
100
|
66
|
|
|
30
|
unless (ref($sub) and reftype($sub) eq 'CODE'){ |
43
|
1
|
|
|
|
|
26
|
croak "$sub is not a code reference"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
7
|
sub_fullname($sub); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__PACKAGE__ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |