Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: how to iterate over multiple hashes with same key value

by hdb (Prior)
on Jul 02, 2013 at 06:12 UTC ( #1041961=note: print w/ replies, xml ) Need Help??


in reply to how to iterate over multiple hashes with same key value

I see two options:

  1. As per your script, you populate %hash and %population%location in such a way that they have the same keys. So you could just move the print statement from your "locations" loop into the "users" loop (it would also make sense to rename %hash to %users).
  2. Alternatively, you could add another dimension to your %hash such that you store both times and locations in the hash. For example:
    push (@{$hash{$word2}{'times'}},$word1); push (@{$hash{$word2}{'locations'}},$word3);
    This way you would keep the data closer together.

EDIT: Changed %population to %location (thanks kcott)


Comment on Re: how to iterate over multiple hashes with same key value
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2014-09-22 23:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (208 votes), past polls