Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^2: Playing with non-localized $_ in nested loops.by QM (Parson) |
on Aug 23, 2004 at 22:06 UTC ( [id://385244]=note: print w/replies, xml ) | Need Help?? |
Don't be too quick to knock your approach. I find it useful in "real" programs to use a named variable to indicate to my reader (me in most cases :) what I expect that variable to represent. This is especially useful in nested constructs where $_'s semantics change as construct boundaries are crossed.
And if I change a foreach (...) to a while (...), the magic of $_ disappears, and I might introduce bugs similar to gaal's example. Sometimes using explicit variables helps you find logic errors too. -QM
In Section
Seekers of Perl Wisdom
|
|