Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: list all subs in a package

by tdlewis77 (Sexton)
on Aug 06, 2017 at 14:49 UTC ( [id://1196853]=note: print w/replies, xml ) Need Help??


in reply to list all subs in a package

You might like the results of this subroutine better:
use B; collectCode(\%CODE); # collect all subroutines collectCode(\%CODE,\%Term::,"Term::"); # collect from package Term sub collectCode { my ($CODE,$pkg,$prefix) = @_; $pkg = \%:: unless defined($pkg); $prefix = "" unless defined($prefix); foreach my $key (keys %$pkg) { if ($key =~ m/^\w+::$/) { collectCode($CODE,$pkg->{$key},"$prefix$key") unless $prefix eq "" && $key eq "main::"; } else { my $cv; if (ref($pkg->{$key}) eq "CODE") { $cv = B::svref_2object($pkg->{$key}); } elsif (reftype(\$pkg->{$key}) eq "GLOB" && defined(*{$pkg->{$key}}{CODE})) { $cv = B::svref_2object(*{$pkg->{$key}}{CODE}); } $CODE->{"$prefix$key"} = { file => $cv->START->file, line => $cv->START->line } if defined($cv) && ref($cv->START) ne "B::NULL"; } } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1196853]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-23 19:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found