in reply to Re: How to extract the number of cols from a matrix?
in thread How to extract the number of cols from a matrix?
Instead of counting the well-formed rows when trying to determine the existence of malformed rows, I'd count the malformed ones. In effect, you're using double negation ("no not well-formed rows"), which is less clear than the straightforward approach.
die '@mat malformed' if grep { @{$_} != @{$mat[0]} } @mat;
|
|---|