Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: hash name as a variable?

by jeremyh (Beadle)
on Sep 15, 2004 at 16:07 UTC ( #391228=note: print w/ replies, xml ) Need Help??

in reply to hash name as a variable?

Ronnie, I would set it up in a single hash like this:

my ($db, $key); my %DBs = ( "ISWLIVE" => { "LIVE1" => "/usr/local/bin", "LIVE2" => "whatever" }, "Next DB" => { "LIVE1" => "/usr/local/bin", "LIVE2" => "whatever" } ); # etc. for all your DB's and key/values

Then you can iterate through the keys of %DBs like this:
foreach $db ( sort keys %DBs ) { foreach $key ( sort keys %{ $DBs{$db} } ) { printf "DB = %s, key = %s, value = %s\n", $db, $key, $DBs{$db}->{$key}; # do whatever processing you want } }

Comment on Re: hash name as a variable?
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2015-01-30 09:41 GMT
Find Nodes?
    Voting Booth?

    My top resolution in 2015 is:

    Results (248 votes), past polls