PERL: How do I get both sizes of a matrix?

Hi everybody,

I have a matrix called @matrix dinamically built in PERL, so I don't know its exact sizes. It is a 2-dimensional matrix, so its elements are for example:

$matrix[0][0]
$matrix[0][1]
$matrix[1][0]
$matrix[1][1]
$matrix[2][0]
etc...

I know i can get the number of the rows of the matrix with the commands:

$#matrix
scalar @matrix
$n_rows = @matrix

but I don't know how to get the number of the colums of the matrix!
I tried several ways like:

$#matrix[0]
scalar @matrix[0]
$n_cols = @matrix[0]

but they haven't worked.

Can someone help me please? Thank you in advance,

 Sergio.

Although it's valid only for a column 0. try

$#{$matrix[0]}
scalar @{$matrix[0]}
$n_cols = @{$matrix[0]}

Great! It works! I just needed the {} brackets! :stuck_out_tongue: Thank you so much kahuna