Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by kyle (Abbot)
on Apr 08, 2009 at 19:38 UTC ( #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.


Comment on Re: pushing onto array is not working as intended..
Select or Download Code
Re^2: pushing onto array is not working as intended..
by spstansbury (Scribe) 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...
Re^2: pushing onto array is not working as intended..
by ikegami (Pope) 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;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2014-08-02 08:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (55 votes), past polls