possibly depending on an undocumented implementation detail of my version of Perl.

You most definitely are. The loop is suppose to take a list over which to iterate, but you're relying on the observable differences between that an the actual optimised implementation. You can see this by changing foreach (@arr) to what should be equivalent foreach ((),@arr).