Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Build a list of defined var's

by ramlight (Friar)
on Oct 20, 2009 at 18:26 UTC ( [id://802283]=note: print w/replies, xml ) Need Help??


in reply to Build a list of defined var's

It could be easy with a little preparation. You would have to define all of your variables as entries in a hash. Then you could iterate through all of the keys in the hash.
$variable{'a'} = 1; $variable{'b'} = $variable{'a'} + 1; foreach my $k (keys %variable) {$variable{$k} = $reset_value;}
Of course your code would look rather ugly. But sometimes this approach can be useful.

Replies are listed 'Best First'.
Re^2: Build a list of defined var's
by CountZero (Bishop) on Oct 20, 2009 at 18:48 UTC
    Nice try! As a matter of fact, all variables are already in a hash: %main:: for the main package.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-18 06:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found