in reply to Last element index with array refs

Hmmm, I think I got it now:
my $dref = @$list->[0]; my $num = $#{$dref};

Replies are listed 'Best First'.
Re: Re: Last element index with array refs
by ihb (Deacon) on Feb 10, 2003 at 01:20 UTC

    No. Certainly not. Contrary to popular belief, you should not use @ when getting a value from an array. Just as you don't do @array[0], but rather $array[0]. You're using a sigil and the arrow, and are thus doubly dereferencing. The arrow is the dereferencing operator. That means you don't have to put any other extra sigil in front of the reference. See Re: Re: passing object references into subs for another reply of mine covering the very same issue, and gives pointers to documentation that lets you know that this isn't supposed to work, but mysteriously it does anyway.

    ihb