will blow away the values in @array because of the way foreach aliases $_ with the elements, and that function happens to (implicitly) use $_.foreach (@array) { ... $f = getfile($filename); ... }
So if that's such a problem, why don't we run into it more often? Should we write all our functions to localize $_ just in case someone wants to call it within a foreach loop? Or should the coder of a foreach name his variable or localize it himself if his body is nontrivial?
—John
In reply to Should we Localize $_ ? by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |