I need a list of all the subs brought in by the file, not all the subs in the current or main package, and file.pm does not conatin any package declarations.
You can require that file in an ad-hoc package and inspect its symbol table:
#!/usr/bin/perl # file.pm use strict; our ($baz, $quux); sub blorf; $quux = sub { 3 }; sub foo { 1 } sub bar { 2 }
#!/usr/bin/perl # main script use strict; { package Query; require "file.pm"; } print "in package ", __PACKAGE__, $/; for my $sym ( keys %Query:: ) { no strict 'refs'; print "file.pm: $sym\n" if defined *{'Query::'.$sym}{CODE}; print "file.pm: subref \$$sym\n" if ref ${*{'Query::'.$sym}{SCALAR}} + eq 'CODE'; }
Output:
in package main file.pm: sub bar file.pm: subref $quux file.pm: sub blorf file.pm: sub foo
In reply to Re: List of subs defined by a file?
by shmem
in thread List of subs defined by a file?
by exodist
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |