The Devel namespace has lots of modules you can use for this sort of thing. You can, however, get some information on your own from the symbol table. Here is a simple illustration of that sort of thing from the command line,
The BEGIN block collects all the keys of %main:: which exist before other stashes are formed and uses them as keys in the %ns hash. That hash is used to eliminate the 'noise' leaving only the names you have defined since.$ perl -e'BEGIN{@ns{keys %::} = ()}; $foo = "bar";@names = grep {!exis +ts $ns{$_}} keys %::; print "@names",$/' foo names $
That could be carried further by checking names against properties by the likes of,
The values may be examined by dereferencing. Again the command line,print "foo has: ", $_, $" for (grep {*foo{$_} qw/SCALAR ARRAY HASH CODE GLOB IO/;
All this only addresses the symbol tables. Lexical variables are not accessible by this method.$ perl -e'BEGIN{@ns{keys %::} = ()}; $foo = "bar";@names = grep {!exis +ts $ns{$_}} keys %::; print ${*foo{SCALAR}} ,$/' bar $
After Compline,
Zaxo
In reply to Re: Listing all Constants and values
by Zaxo
in thread Listing all Constants and values
by gwhite
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |