Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by Athanasius (Chancellor)
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002918]
help
Chatterbox?
[LanX]: inspect %INC ?
[Lady_Aleena]: LanX, for every module I've written?
[huck]: Lady_Aleena see Re: pl script in webserver and/or Re: pl script in webserver for what they use
[Lady_Aleena]: Wouldn't I have to run the modules somehow to get their %INC?
[huck]: the first one works just fine from the command line but requires editing
[huck]: but neither will handle autoloads

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2017-05-27 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?