Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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

by hdb (Monsignor)
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)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1041961]
[Your Mother]: Comfort food and diabetes for the soul.
[LanX]: talking about comic adaptions ... I really liked the Watchmen
[LanX]: look I can give you a long list of excellent US movies
[Your Mother]: I adored the comic and the movie was almost a frame for frame remake (excepting the plot liberties to shorten it) but I still didn't quite like it. What's his nose, Jamie Earl whoever was flawless though.
LanX though probably produced outside Holywood
[Your Mother]: There are tons of good movies from all over but for every gem there is a pile of dirt 10 meters high burying it.
[LanX]: well
[LanX]: who's Jamie Earl?
[Your Mother]: Also: I am old and complaining is my hobby.
[LanX]: BTW: have you ever seen Network?

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (14)
As of 2018-03-19 15:00 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.