The use of $_ in a foreach doesn't add much risk or cause much reduction in the robustness of the code. foreach, like map and grep, will always localize $_ within its scope.
There is only the slight risk of the function mucking with $_ (as the original poster's original function did); however, any function that uses or modifies a non-localized $_ is broken.
In reply to Re^4: Strange Global Array issue
by topher
in thread Strange Global Array issue
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |