Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re^4: Strange Global Array issueby topher (Scribe) |
on Apr 16, 2013 at 17:39 UTC ( [id://1028974]=note: print w/replies, xml ) | Need Help?? |
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.
Christopher Cashell
In Section
Seekers of Perl Wisdom
|
|