in reply to Devel::GetSymbols (fka Symbol::List)

If I understand what you're saying....you're replacing the following:
use Exporter(); @ISA=qw(Exporter); @EXPORT_OK=qw(sub1 sub2 sub3 ... subn);
with:
use Symbol::List; @EXPORT_OK = Symbol::List::symbols('CODE');
That isn't saving much effort but it's a nice idea nonetheless. :)

I think it would unnecessarily export private subs too! That is something you might not want to do.

metadoktor

"The doktor is in."

Replies are listed 'Best First'.
Re: Re: Symbol::List
by busunsl (Vicar) on Jan 23, 2002 at 16:48 UTC
    Well, think of a module which contains just constants used in other modules/programs.
    And imagine you have LOTS of them!

    You'll love a way to export them with something simple like @EXPORT_OK = Symbol::List::symbols('CODE');.

    I think the module is a great idea.

Re: Re: Symbol::List
by Juerd (Abbot) on Jan 23, 2002 at 18:11 UTC
    Please note: It's not just for exporting subs. Symbol::List::symbols returns a list of symbols, which can be useful in many ways. If it were just for exporting, I'd probably have created Exporter::ExportAll :)

    Only lexicals are private, and those aren't in the symbol table. Naming a sub so it starts with an underscore means it's "private" in many cases, but doesn't have to. grep is great for selecting things, and it's not hard at all:
    grep !/^_/, symbols('CODE'); # non-"privates" grep !/[^A-Z0-9_]/, symbols('CODE'); # "constants"

    2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$