in reply to Re^4: Negative array subscript method call bug?
in thread Negative array subscript method call bug?
It's a case of which error came first.
In this first case, $x[ 0 ] exists, so $x[ -1 ] can be translated as
$x[ @x - 1 ] ==> $x[ 1 - 1 ] ==> $x[ 0 ]
which is valid and currently undef, so the error occurs when try to indirect through undef for the method call.
P:\test>perl -e" @x = undef; $x[ -1 ]->fred()" Can't call method "fred" on an undefined value at -e line 1.
But in this case you have $x[ 0 - 1 ], which translates to a post-normalisetion, negative index (-1), which is illegal.
So that's the error you see, and the indirection is never attempted.
P:\test>perl -e" $x[ -1 ]->fred()" Modification of non-creatable array value attempted, subscript -1 at - +e line 1.
Of course, the subscript normalisation also incorporates $[, but the always 0...right :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Negative array subscript method call bug?
by BUU (Prior) on Aug 08, 2004 at 09:19 UTC | |
by demerphq (Chancellor) on Aug 08, 2004 at 10:55 UTC | |
by BUU (Prior) on Aug 08, 2004 at 20:04 UTC | |
by BrowserUk (Patriarch) on Aug 09, 2004 at 10:06 UTC | |
by ysth (Canon) on Aug 09, 2004 at 19:20 UTC | |
by BrowserUk (Patriarch) on Aug 09, 2004 at 19:40 UTC | |
|