in reply to Re^3: how internally $#array is working in Perl
in thread how internally $#array is working in Perl
You're not even limited to positive numbers.
$ perl -wle'$[ = -3; $_ = "abcdef"; print substr($_,0,1)' Use of assignment to $[ is deprecated at -e line 1. d
You could get weird constructs that caused Perl to crash:
$ perl -we'$[ = 3; $_ = "abc"; my $x = substr($_,2,1)' panic: sv_setpvn called with negative strlen at -e line 1.
I fixed it in 5.10.1 or 5.12.0 when fixing another bug:
$ perl -we'$[ = 3; $_ = "abc"; my $x = substr($_,2,1)' Use of assignment to $[ is deprecated at -e line 1. substr outside of string at -e line 1.
Keep in mind $[ is slated to be removed from Perl.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: how internally $#array is working in Perl
by DrHyde (Prior) on Aug 16, 2010 at 09:51 UTC | |
by Corion (Patriarch) on Aug 16, 2010 at 09:55 UTC |