in reply to How to extract the number of cols from a matrix?
If the rows of a matrix are well-constructed, each will have the same number of elements, even if some elements are undefined. my $cols = @{$mat[0]}; To check for that goodness,
The equality tests put all those arrays in scalar context, so their counts are what is tested.@mat == grep { @{$_} == @{$mat[0]}; } @mat or die '@mat not well-formed';
See tye's References quick reference for a concise key to understanding reference manipulations.
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to extract the number of cols from a matrix?
by ikegami (Patriarch) on Jun 26, 2005 at 14:04 UTC |