line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::Caller::Util; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2019-04-12'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.042'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
55486
|
use warnings; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
30
|
|
7
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
3
|
use Exporter qw(import); |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
241
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw(caller callers); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $_is_caller; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub callers { |
15
|
8
|
|
|
8
|
1
|
16
|
my ($start, $with_args, $packages_to_ignore, $subroutines_to_ignore) = @_; |
16
|
8
|
100
|
|
|
|
17
|
$start = 0 unless defined $start; |
17
|
|
|
|
|
|
|
|
18
|
8
|
|
|
|
|
12
|
my @res; |
19
|
8
|
|
|
|
|
9
|
my $i = 1; |
20
|
|
|
|
|
|
|
|
21
|
8
|
|
|
|
|
11
|
while (1) { |
22
|
11
|
|
|
|
|
12
|
my @caller; |
23
|
11
|
50
|
|
|
|
21
|
if ($with_args) { |
24
|
|
|
|
|
|
|
{ |
25
|
0
|
|
|
|
|
0
|
package # hide from PAUSE |
26
|
|
|
|
|
|
|
DB; |
27
|
0
|
|
|
|
|
0
|
@caller = caller($i); |
28
|
0
|
0
|
|
|
|
0
|
$caller[11] = [@DB::args] if @caller; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} else { |
31
|
11
|
|
|
|
|
42
|
@caller = caller($i); |
32
|
|
|
|
|
|
|
} |
33
|
11
|
100
|
|
|
|
23
|
last unless @caller; |
34
|
6
|
|
|
|
|
16
|
$i++; |
35
|
|
|
|
|
|
|
|
36
|
6
|
100
|
|
|
|
13
|
if ($packages_to_ignore) { |
37
|
3
|
50
|
|
|
|
8
|
if (ref $packages_to_ignore eq 'ARRAY') { |
38
|
3
|
100
|
|
|
|
7
|
next if grep { $_ eq $caller[0] } @$packages_to_ignore; |
|
3
|
|
|
|
|
11
|
|
39
|
|
|
|
|
|
|
} else { |
40
|
0
|
0
|
|
|
|
0
|
next if $caller[0] =~ $packages_to_ignore; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
5
|
50
|
|
|
|
22
|
if ($subroutines_to_ignore) { |
45
|
0
|
0
|
|
|
|
0
|
if (ref $subroutines_to_ignore eq 'ARRAY') { |
46
|
0
|
0
|
|
|
|
0
|
next if grep { $_ eq $caller[3] } @$subroutines_to_ignore; |
|
0
|
|
|
|
|
0
|
|
47
|
|
|
|
|
|
|
} else { |
48
|
0
|
0
|
|
|
|
0
|
next if $caller[3] =~ $subroutines_to_ignore; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
5
|
|
|
|
|
11
|
push @res, \@caller; |
53
|
5
|
100
|
66
|
|
|
25
|
do { $_is_caller = 0; return @caller } if $_is_caller && @res == $start+1; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
20
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
5
|
100
|
|
|
|
12
|
splice @res, 0, $start if $start; |
57
|
5
|
|
|
|
|
9
|
$_is_caller = 0; |
58
|
5
|
|
|
|
|
23
|
@res; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub caller { |
62
|
8
|
|
|
8
|
1
|
10118
|
$_is_caller = 1; # "local" doesn't work here |
63
|
8
|
|
|
|
|
26
|
goto &callers; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
# ABSTRACT: caller()-related utility routines |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |