Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Pushing values into an array of hashes

by RichardK (Vicar)
on Aug 09, 2012 at 14:55 UTC ( #986539=note: print w/ replies, xml ) Need Help??


in reply to Pushing values into an array of hashes

I think you'll find the problem is you're pushing a reference to %rec to your @DA each time, but you only have one instance of %rec, i.e. all your references point to the same thing.

So if you move the definition of %rec inside the loop it should do what you want.

So something like this

for (@buckets) { my %rec; ... push @DA,\%rec; }


Comment on Re: Pushing values into an array of hashes
Download Code
Replies are listed 'Best First'.
Re^2: Pushing values into an array of hashes
by rizzler (Novice) on Aug 09, 2012 at 14:58 UTC
    Cheers, It worked perfectly :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2015-07-31 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (275 votes), past polls