Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: array of arrays

by dreadpiratepeter (Priest)
on Jun 29, 2009 at 13:06 UTC ( [id://775653]=note: print w/replies, xml ) Need Help??


in reply to array of arrays

the syntax is wrong, what you need is
push @{$aod[$id]},$value;
@aod[$id] would be a 1 element array slice.
with @{$aod[$id]} you are saying that the scalar in position $id in your outer array, is to be used as a reference to an array. Since push needs to be passed an array, not a reference, you use the dereferencing syntax @{} to give it what it needs.
The first time you push on a particular element the nested array gets auto-vivified, that is automatically created when needed.


-pete
"Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-23 06:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found