in reply to 2 dimensional array question

you need square brackets...
$arr[0] = [1,2,3]; $arr[1] = [4,5,6]; $index=1; print "$arr[$index][2]";
The square bracket returns a reference to an anonymous array. Your example is just a list, which is forced to scalar context (you're putting it into the first element of your array) which just returns the last element in your list. You can prove this by printing $arr[0];

You might also have noticed I changed the @'s to $'s, which it prefered when referencing a single element of an array...

my @array = (1,2,3); my $array[0] = 4;
If you run your program with warnings on, it will tell you this.

references are a big subject, you might want to check out ...

perldoc perlref
or "Learing/Programming Perl" which are excellent books.
---
my name's not Keith, and I'm not reasonable.

Replies are listed 'Best First'.
Re^2: 2 dimensional array question
by redss (Monk) on Sep 05, 2005 at 14:50 UTC
    ah yes, the square brackets did the trick. thanks!