Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Assigning an Array to a Multidimensional Array

by premchai21 (Curate)
on Apr 23, 2002 at 16:10 UTC ( #161352=note: print w/ replies, xml ) Need Help??


in reply to Assigning an Array to a Multidimensional Array

"Without using references"? By using two-dimensional arrays, you are already using references; two-dimensional arrays are actually arrays of arrays. See perlref, perldsc, perllol.

What you are looking for, I think, is the anonymous arrayref generator, which is a set of square brackets with a list inside, evaluating to a reference to a new anonymous array, contents being that list. Then you assign the reference to one of the elements of the "topmost" array. So, for example:

$two[4] = [ @one ];

will cause element 4 of @two (the two-dimensional array) to contain a reference to an anonymous array initialized from @one (a one-dimensional array), thus assigning @one to row 4 (counting from 0, assuming the indexing goes row, column). Again, see perlref, perldsc, perllol.


Comment on Re: Assigning an Array to a Multidimensional Array
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (20)
As of 2015-07-31 16:19 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 (279 votes), past polls