in reply to Re: List of subs defined by a file?
in thread List of subs defined by a file?
My code, for what it's worth:
#!/usr/bin/perl # listsubs - display list of subroutines in a package or script use strict; my $file=shift @ARGV; { package Query; require $file; } for my $sym ( keys %Query:: ) { no strict 'refs'; print "Query::$sym\n" if defined *{'Query::'.$sym}{CODE}; print "$file: subref \$$sym\n" if ref ${*{'Query::'.$sym}{SCALAR}} e +q 'CODE'; }
I think the right answer to this is to simply grep the file for /^sub/, unless you're trying to get a list of dynamically generated coderefs??
SSF
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: List of subs defined by a file?
by shmem (Chancellor) on Dec 21, 2008 at 16:57 UTC |