In a word, aliasing. Foreach loop variables are aliased to the elements they are iterating over. Modifying the loop variable modifies the original element.
If you hard-code your list into the loop, instead of using an array, you'll get an error when it tries to modify it.
The PerlMonk tr/// Advocate
Comment on Re: Variable scoping, foreach loop, alias