File Coverage

blib/lib/Devel/Wherefore.pm
Criterion Covered Total %
statement 15 21 71.4
branch 0 4 0.0
condition n/a
subroutine 5 6 83.3
pod n/a
total 20 31 64.5


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