Note that, unlike other compile-time directives (such as strict), assignment to $[ can be seen from outer lexical scopes in the same file. However, you can use local() on it to strictly bound its value to a lexical block.
from perldoc perlvar
So I don't have to worry that someone will change mine $[ from within a different file that I used, but I still might run into problems if someone fiddles with $[ somewhere above my code in the same file.
@a = (0,1,2,3,4,5); sub pr { print "sub \$a[2]=$a[2]\n"; } print "\$a[2]=$a[2]\n"; pr; { $[ = 1; print "\$a[2]=$a[2]\n"; pr; } print "\$a[2]=$a[2]\n"; pr;
I refuse to worry anyway.
In reply to Re^3: Reference assessment techniques and how they fail ($[)
by Jenda
in thread Reference assessment techniques and how they fail
by kyle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |