line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::Wherefore; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.000002'; # v0.0.2 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
609
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
9
|
1
|
|
|
1
|
|
5
|
use B (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
10
|
1
|
|
|
1
|
|
484
|
use Sub::Identify qw(sub_fullname get_code_location); |
|
1
|
|
|
|
|
1003
|
|
|
1
|
|
|
|
|
64
|
|
11
|
1
|
|
|
1
|
|
510
|
use Package::Stash; |
|
1
|
|
|
|
|
8068
|
|
|
1
|
|
|
|
|
393
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# detect -d:Wherefore and disable debugger features |
14
|
|
|
|
|
|
|
if (!defined &DB::DB && $^P & 0x02) { |
15
|
|
|
|
|
|
|
$^P = 0; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub import { |
19
|
0
|
|
|
0
|
|
|
our (undef, $pkg) = @_; |
20
|
0
|
0
|
|
|
|
|
unless ($pkg) { |
21
|
0
|
0
|
|
|
|
|
if (my ($path) = $0 =~ m{^(?:lib/)?(.*)\.pm$}) { |
22
|
0
|
|
|
|
|
|
$pkg = join '::', split '/', $path; |
23
|
|
|
|
|
|
|
} else { |
24
|
0
|
|
|
|
|
|
$pkg = 'main'; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
0
|
|
|
|
|
|
B::minus_c; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub CHECK { |
31
|
|
|
|
|
|
|
return unless our $pkg; |
32
|
|
|
|
|
|
|
my $subs = Package::Stash->new($pkg)->get_all_symbols('CODE'); |
33
|
|
|
|
|
|
|
print "# Symbols found in package ${pkg} after compiling $0\n"; |
34
|
|
|
|
|
|
|
foreach my $name (sort keys %$subs) { |
35
|
|
|
|
|
|
|
my $fullname = sub_fullname $subs->{$name}; |
36
|
|
|
|
|
|
|
my ($file, $line) = get_code_location $subs->{$name}; |
37
|
|
|
|
|
|
|
print join("\t", |
38
|
|
|
|
|
|
|
map +(defined() ? $_ : "\\N"), ${name}, ${fullname}, ${file}, ${line} |
39
|
|
|
|
|
|
|
)."\n"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
close(STDERR); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Devel::Wherefore - Where the heck did these subroutines come from? |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SYNOPSIS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$ perl -d:Wherefore myscript.pl |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
will dump symbols in main from myscript.pl |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$ perl -d:Wherefore=App::opan $(which opan) |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
will dump symbols from package App::opan in the installed opan script |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$ perl -d:Wherefore lib/Foo/Bar.pm |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
will dump symbols from package Foo::Bar (must be in lib/ or at root, doesn't |
63
|
|
|
|
|
|
|
yet handle finding them in @INC, sorry). |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Note that this code uses C to only compile the script so you |
66
|
|
|
|
|
|
|
don't have to worry about it executing - does mean we'll miss runtime |
67
|
|
|
|
|
|
|
require and import but hey, trade-offs. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 DESCRIPTION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Rage driven development rapidly released. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 AUTHOR |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
mst - Matt S. Trout (cpan:MSTROUT) |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
None yet - maybe this software is perfect! (ahahahahahahahahaha) |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 COPYRIGHT |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Copyright (c) 2020 the Devel::Wherefore L and L |
84
|
|
|
|
|
|
|
as listed above. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 LICENSE |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This library is free software and may be distributed under the same terms |
89
|
|
|
|
|
|
|
as perl itself. |