http://qs321.pair.com?node_id=11119875


in reply to What array negative number counting means

As an historical aside, note that using the result of evaluating the expression  (scalar @ra) - 1 is not quite the same as using an index of -1 or $#array if you have set the array base $[ (which defaults to 0) to be 1 — but don't do that! See $[ in Deprecated and removed variables in perlvar. Assignment to $[ was first deprecated in Perl version 5.12 and has been increasingly constrained in subsequent versions.

c:\@Work\Perl\monks>perl -wMstrict -le "$[ = 1; ;; my @ra = qw(zero one two three); ;; print scalar @ra; print 0 + @ra; print $ra[ (scalar @ra) - 1 ]; print $ra[ @ra - 1 ]; print $ra[ @ra ]; print $ra[ -1 ]; print $ra[ $#ra ]; " Use of assignment to $[ is deprecated at -e line 1. 4 4 two two three three three
In all cases (and regardless of the array base — but again, don't futz with that):


Give a man a fish:  <%-{-{-{-<