Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How to I retrieve a specific key/value from a hash?

by aijin (Monk)
on May 15, 2001 at 22:23 UTC ( #80660=note: print w/ replies, xml ) Need Help??


in reply to How to I retrieve a specific key/value from a hash?

Basically what you're trying to do is create similarly named variables, right? It looks like you're trying to concatenate the base for the variable name with the number, and that's not going to work. You could use an associative array...especially since you seem to be using numbers as the differentiating factor in your naming scheme.

Thus, you can go about it like this:

my (%graphic, %url); for ($i=0; $i<2; $i++) { $graphic{$i} = $foo; $url{$i} = $bar; }

Then when you wish to print, say, the second graphic, you would use:

print $graphic{2};

Hope this was of some help to you.


Comment on Re: How to I retrieve a specific key/value from a hash?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2014-07-29 06:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls