Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: the ref use the same memory when i push structure onto array? Gahh .. please help me dear perl-gurus

by eric256 (Parson)
on Mar 09, 2010 at 14:11 UTC ( #827537=note: print w/ replies, xml ) Need Help??


in reply to the ref use the same memory when i push structure onto array? Gahh .. please help me dear perl-gurus

you could also just add a my $rr; at the top of the loop to make sure you where starting with a new $rr everytime through. You could also use hash slices to simply the split a little

foreach (@rooms) { my $rr; @$rr{ qw/TITLE TEXT EXITS THINGS ITEMS/ } = split ":", $_; push @a, $rr; }; return \@a;


___________
Eric Hodges


Comment on Re: the ref use the same memory when i push structure onto array? Gahh .. please help me dear perl-gurus
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (16)
As of 2015-07-07 22:06 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 (93 votes), past polls