http://qs321.pair.com?node_id=410358

```my @row0 = (1, 0, 0);
my @row1 = (0, 1, 0);
my @row2 = (0, 0, 1);
my @arr = ( \@row0, \@row1, \@row2 );
for ( \$i = 0; \$i < 3; \$i++ ) {
for ( \$j = 0; \$j < 3; \$j++ ) {
print "arr[\$i][\$j] = \$arr[\$i][\$j]\n";
}
} # works perfectly
print "*" x 80, "\n";
my @another = \\$arr;
for ( \$i = 0; \$i < 3; \$i++ ) {
print "another[\$i] = \$another->[\$i]\n";
} # while this loop prints blanks
what am i doing wrong ?

Replies are listed 'Best First'.
Re^2: Multidimensional Arrays
by chb (Deacon) on Nov 25, 2004 at 10:02 UTC
You could try:
```my @another = @{\$arr};
for ( \$i = 0; \$i < 3; \$i++ ) {
print "another[\$i] = \$another[\$i]\n";
}
using an array to hold the row, or:
```my \$another = \$arr;
for ( \$i = 0; \$i < 3; \$i++ ) {
print "another[\$i] = \$another->[\$i]\n";
}
using a ref to the row. You should also consider use strict;, BTW...
Re^2: Multidimensional Arrays
by wfsp (Abbot) on Nov 25, 2004 at 10:12 UTC
my @another = \\$arr;

@another has a single element - a reference to a reference to an array.

Try:

\${\${\$another}}[\$i]

Update: fixed typo

This works, too:
```@{\${\$another}}[\$i]