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

Re: Build a list of defined var's

by ramlight (Friar)
on Oct 20, 2009 at 18:26 UTC ( #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.


    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?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2023-09-30 15:11 GMT
Find Nodes?
    Voting Booth?

    No recent polls found