in reply to last index of array ref...
$aref = [qw/1 2 3/]; print $#$aref; print $#{$aref}; # it is not the same as scalar(@$aref) print scalar(@$aref); [download]