in reply to Re^4: Negative array subscript method call bug?
in thread Negative array subscript method call bug?

That doesn't strike me as a very legitimate reason, because method invocation isn't the only place where this happens. hence the other example I posted...

laptop:~> perl -e '$y = \$x[-1000];' Modification of non-creatable array value attempted, subscript -1000 a +t -e line 1.

...there's nothing remotely close to a modification there.

Replies are listed 'Best First'.
Re^6: Negative array subscript method call bug?
by demerphq (Chancellor) on Aug 09, 2004 at 09:26 UTC

    ...there's nothing remotely close to a modification there.

    Sure there is. The reference operator must have something to reference. And inorder to reference an element of an array the array element must exist. Thus before the reference can be taken it tries to create the element, but fails because it makes no sense. Try doing the same thing but with a positive index, and then print out how large the array is afterwards....


    ---
    demerphq

      First they ignore you, then they laugh at you, then they fight you, then you win.
      -- Gandhi


Re^6: Negative array subscript method call bug?
by ysth (Canon) on Aug 09, 2004 at 10:05 UTC
    Literally, you are correct, and the error message is misworded. However, this is an example of what I'm going to call for lack of a better term "modification context". Same applies to &foo($x[-1000]) or $x[-1000]->foo. That's what the error message is referring to.