no strict 'refs';
for ( keys %{"main::"} ) {
print "$_\n" if defined *{"main::$_"}{CODE};
}
If you want to know subroutines of everything loaded, then you can use the %INC hash, convert back to module names, and search through all of them for subroutines:
my @subs;
for my $mod ( keys %INC ) {
$mod =~ s!/!::!g;
$mod =~ s/.pm$/::/;
{
no strict 'refs';
for ( keys %{$mod} ) {
push @subs, $mod . $_ if defined *{$mod . $_}{CODE};
}
}
}
print "$_\n" for @subs;
(Note that this won't find subroutines that are explicitely loaded into a package that isn't named the same as the file that was required or used.)
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|