Forcing an rvalue context on a scalar expression

Explaination of what's going on

As well as getting an answer to my question I also set Abigail, Uri and Anno off on a discussion of why the original behaviour occured at all and wether or not it was a bug. (Not that I had been in any doubt at all).

The problem is your use of -1 as index on an empty array. An empty array has no elements, so it certainly doesn't have a last element. Due to Perl using 'call by implicit reference' when calling functions with arguments, it must know which element you mean, just in case foo assigns to $_[0].

sub foo { $_[0] = 1 }
my @q;
foo $q[2];
print scalar @q;

This prints 3 because you created $q[2]. But suppose you had called foo $q[-1] how large should @q be afterwards? Which element was created?

Of course the subroutine call and the empty array are not actually relevant, you get the same if you do.

my @q = ( 'foo' );
my $r = \$q[-2];

Next