Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: pushing onto array is not working as intended..

by kyle (Abbot)
on Apr 08, 2009 at 19:38 UTC ( [id://756435]=note: print w/replies, xml ) Need Help??


in reply to pushing onto array is not working as intended..

This line:

push @{$records}, %record;

...should be:

push @{$records}, \%record;

...as you have everywhere else.

Update: Actually, that's not going to do what you want either. Change them all to:

push @{$records}, { %record };

With what you have, you'll end up with an array of references to the same hash. You want to construct a new hash every time you push, and the above syntax will do that.

Replies are listed 'Best First'.
Re^2: pushing onto array is not working as intended..
by ikegami (Patriarch) on Apr 08, 2009 at 21:23 UTC
    Seems to me you fixed the wrong line in your update. I consider
    %record = (); ... push @{$records}, { %record };
    much worse than
    my %record; ... push @{$records}, \%record;
Re^2: pushing onto array is not working as intended..
by spstansbury (Monk) on Apr 08, 2009 at 20:47 UTC
    Yes, that's exactly what I wanted.
    The syntax is NOT second nature yet...

    Thank you very much!

    Scott...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-25 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found