Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Print variable name/value for all program variables

by Athanasius (Monsignor)
on Nov 08, 2012 at 14:56 UTC ( #1002918=note: print w/ replies, xml ) Need Help??


in reply to Re: Print variable name/value for all program variables
in thread [SOLVED] - Print variable name/value for all program variables

Yes. Include a package declaration at the head of your script, then you can get the names of the variables (and subroutines) as follows:

0:51 >perl -E "package Foo; $x = 42; $y = 'fred'; sub command { print + 'Special command'; } say for sort keys %Foo::;" command x y 0:54 >

Hope that helps,

Athanasius <°(((><contra mundum


Comment on Re^2: Print variable name/value for all program variables
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-08-30 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (291 votes), past polls