in reply to Changing array by changing $_?

There are several features of for/foreach loops that are not obvious. If the aliasing feature is new to you, you might review the sections on for and foreach in the perlsyn man page. Familiarity may help you avoid other troublesome surprises.