in reply to simple matrix

Thanks to all of you. Appologies for the sloppy coding, I thought I was saving time in trying to do this little test, but obviously that doesn't pay!! I needed to keep using @row to add to the array because this will happen in a loop, so as long as variables are local and I contain it in {} it works - great! The hash of arrays is probably my best bet as all users have unique usrName.

Replies are listed 'Best First'.
Re^2: simple matrix
by ikegami (Patriarch) on May 04, 2006 at 16:40 UTC

    Here's an updated solution given the new context.

    Doesn't work:

    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,