in reply to confusing question, involving multidemensional arrays

How do I find out how many references I have in one of my arrays?
Like.. $#array = how many references are in that array... i want to do something like $#array[1], but that doesn't work.

Replies are listed 'Best First'.
Re: Re: confusing question, involving multidemensional arrays
by Zed_Lopez (Chaplain) on Aug 10, 2001 at 02:20 UTC

    $#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.