Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: building array of hashes

by Eily (Parson)
on Jun 28, 2013 at 19:35 UTC ( #1041324=note: print w/replies, xml ) Need Help??

in reply to building array of hashes

Since you do not declare your hash inside of your for loop, it is always the same one you push into the array. You do not have a new one with new values, you just replace them.

There are two things you can do. Either declare your hash lexically (with my) inside the for loop, and you'll have a brand new one each time, or youcan make a new one to push into AOH. With push @AOH, { %hash }; # copy of %hash here

Both are possible, but it would probably be better to have your my %hash in the for loop, because you can be sure to have only new values, not ones that you somehow didn't delete or change.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1041324]
and the radiator hisses contentedly...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2018-01-20 23:40 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (227 votes). Check out past polls.