in reply to How to get Matrix Size
Howdy David, welcome back to the Monastery!
I'm a little surprised that you're getting a value of 3 by evaluating @myMatrix in a scalar context; it should be 2, since @myMatrix is a list with two elements (which just so happen to be array references).
You can get the number of rows and columns in your matrix like this:
$rows = @myMatrix; $cols = @{ $myMatrix[0] };
That said, I'd suggest using an existing module for working with matrices instead of rolling your own, unless there's a compelling reason not to. A quick CPAN search finds e.g. Math::GSL::Matrix and Math::Matrix.
|
|---|