for (...) {
@row = ();
...
push(@maxtrix, \@row);
}
Works:
for (...) {
my @row;
...
push(@maxtrix, \@row);
}
In the first, each row of the matrix is a reference to the same array (@main::row).
In the second, a new lexical is created every time through the loop, so each row of the matrix is a reference to a different array.
For example,
|