Meghan has asked for the wisdom of the Perl Monks concerning the following question:

Can anyone help me with creating two-dimentional arrays (arrays which contain secondary arrays as elements)? I haven't been able to find any online documentation, and although I could get my script to work in other ways, I want to figure out how to do it this way.

Best,
Meghan

Replies are listed 'Best First'.
Re: two-dimentional arrays?
by chromatic (Archbishop) on Feb 15, 2000 at 03:23 UTC
    The appropriate section of perldoc is perlref. You'll probably want to read this, as Perl accomplishes complex data structures (beyond scalars, arrays, and hashes) via references.
      You might want to take a look at perlreftut before you look at perlref.

      perlreftut is the Perl references tutorial. It's shorter than perlref and leaves out a lot of stuff that is rarely used. It also has a simple example.

      It should be available in your documentation set that you got with Perl, but if you can't find it, it's available online at http://www.plover.com/~mjd/perl/FAQs/References.html.

RE: two-dimentional arrays?
by vroom (His Eminence) on Feb 13, 2000 at 11:12 UTC
Re: two-dimentional arrays?
by Anonymous Monk on Feb 13, 2000 at 22:31 UTC
    $array_2d = [[a, b, c], [d, e, f], [g, h, i]]; for $l (0..2) { for $c (0..2) { print $array_2d->[$l][$c]; } }