Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Is it possible to get all variable names which are declared?

by Chuma (Scribe)
on Nov 09, 2017 at 18:03 UTC ( [id://1203075]=note: print w/replies, xml ) Need Help??


in reply to Is it possible to get all variable names which are declared?

Try something like this:
for(keys %{'main::'}){if(defined $$_){print "\$$_\n\t$$_\n"}}

Replies are listed 'Best First'.
Re^2: Is it possible to get all variable names which are declared?
by Laurent_R (Canon) on Nov 09, 2017 at 18:56 UTC
    Looking into the symbol table like that would attempt to access the "global" (package) variables (those defined with our, for example), not to lexical variables (defined with my), which is apparently what the OP was looking for.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1203075]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-18 13:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found