in reply to Array slice out of order

You've got an lvalue and an rvalue there. lvalues are not converted to rvalues until they have to be. So it sees $i and leaves it alone, then sees $i++ and evaluates it (yielding 0 and incrementing $i), then plugs in the value of $i to use for indexing the array.

If you change it to

print @m[$i+0, $i++];
you'll have two rvalues, and they will have been evaluated from left to right, yielding the 'aa' that you want.

It doesn't have to work this way — as others point out, it's undefined behavior when side-effects happen — but this is how it is happening here.


Caution: Contents may have been coded under pressure.