@mat == grep { @{$_} == @{$mat[0]}; } @mat or die '@mat not well-formed';