in reply to Re: confusing question, involving multidemensional arrays
in thread confusing question, involving multidemensional arrays
$#array gives you the highest-numbered index of @array, which is 1 less than the number of elements, because it counts from 0. Evaluating @array in a scalar context gives you the number of elements, an evaluation you can force with scalar @array.
It works great with arrayrefs too... scalar @$arrayref gives you the number of elements in the array to which $arrayref refers; scalar @{$arrayref->[$i]} gives you the number of elements in the array ref that's the ith element in $arrayref.
|
|---|