The described behavior changes whether "sort @arr" goes directly in 'for' or you assign it first to an array variable.
@arr = ('one', 'two', 'three', 'four'); y/a-z/A-Z/ foreach sort @arr; print "\na: @arr\n" prints "a: ONE TWO THREE FOUR" and @arr = ('one', 'two', 'three', 'four'); @s = sort @arr; y/a-z/A-Z/ foreach @s; print "\na: @arr\n" prints "a: one two three four". This has to do with copy-on-assign? That seems like a (subtle) feature. Otherwise, it is a very old bug: the same behavior with 5.8.6, 5.6.1, and 5.005_03.