laziness, impatience, and hubris | |
PerlMonks |
Re: Why is my array getting changed?by jmcnamara (Monsignor) |
on Aug 26, 2002 at 14:42 UTC ( [id://192887]=note: print w/replies, xml ) | Need Help?? |
When you use a for(each) loop in this way it edits the elements of the array in-place:
Here is the relevant detail from the "Foreach Loops" section of perlsyn: If any element of LIST is an lvalue, you can modify it by modifying VAR inside the loop.
--
In Section
Seekers of Perl Wisdom
|
|