I was reading
a tutorial on Perl autovivification and came across this bit of code, testing whether a number was a valid array index:
return unless 0 <= $key && $key < @{$ref} ;
And I thought “meh”, because the author used @{$ref} in a comparison for a valid index.
I would have used && $key <= $#{$ref} (well, actually probably $#$ref) instead.
(
Read more... )