in reply to How to extract the number of cols from a matrix?

Actually, $rows = @mat will only give you the current number of rows. The fact that is is a 4x5 matrix follows only from your definition, not from the array of arrays. If not all elements are set, you can only get the current dimensions, which may differ from your assumed definition...

Paul