in reply to Re^2: A Better Way to Find the Position of the Last Non-Whitespace Character in the Last Element of an Array.
in thread A Better Way to Find the Position of the Last Non-Whitespace Character in the Last Element of an Array.
The following one-liner was run repeatedly with $[ initialized to different values:
Output of successive runs of the one-liner:>perl -wMstrict -le "$[ = 100; my @ra = qw(a b c d e f); print '$[: ', $[, ' -1: ', $ra[-1], ' $#: ', $ra[$#ra];" $[: 100 -1: f $#: f
Perhaps more support for the don't do that part of the discussion in the docs about assigning to $[ a value other than 0?$[: 100 -1: f $#: f $[: 1 -1: f $#: f $[: 0 -1: f $#: f $[: -1 -1: f $#: f $[: -6 -1: f $#: f $[: -7 -1: f $#: e $[: -11 -1: f $#: a Use of uninitialized value in print at -e line 1. $[: -12 -1: f $#: Use of uninitialized value in print at -e line 1. $[: -99 -1: f $#:
(BTW, the latest perlvar sez wrt $[ that As of release 5 of Perl, assignment to $[ is treated as a compiler directive, and cannot influence the behavior of any other file, so old code that plays too fast and loose with $[ may be broken anyway.)
|
|---|