You are assuming that the expression is evaluated in a strict
left-to-right order, which is not necessarily so, particularily
when you use more than one type of operator. That is, in the
is being evaluated before the shift is, so hence the @_ array
is still as it was before the shift. Leftward list operators
have a very high priority (see perlop
), and this makes it
look like perl evaluates the value of the index before the
value of the list itself. To see this more clearly, try:
return ( 1,2,3 );
$a = (adob())[flob()];
Which prints 'Flobadob', indicating that flob() is executed first.
I can't find any docs that indicate that this is the expected
behaviour, so it's probably not something you should rely
upon working in future versions of perl.