From: "Chas. Owens" <[EMAIL PROTECTED]> > Yes, but I am the one making pronouncements about how people should > code. Rob was just calling me on being a little pompous. I still > think that use of $_ in places other than the start of a loop (with a > function that uses the default variable like split, chomp, a regex, > etc) is both dangerous and bad style. It is dangerous because $_ can > be set by any number of things, so the farther from the place that you > set it the more likely a bug will occur. It is bad style becuase $_ > carries no information about what it is being used for. It is easier > to give people simple rules like "only use the default variable with > functions that use it by default" than to explain all of the nuances > of when it adds clarity.
I think the fourth sentence is the best rule. The further from the place you set $_, the more likely you end up with problems. The closer, the safer. And whether you use $_ invisibly, as the default parameter for some builtins or visibly as an ordinary parameter is irrelevant. for (@some_array) { $_ .= "\n"; } would not be made any more clear by changing it to for my $line (@some_array) { $line .= "\n"; } conversely for (@some_array) { fiveteen lines of very involved code calling god knows what s/(blah)/(oops)/g; some more code; } is IMHO fairly unclear no matter that you may be using the $_ only by the builtins behind the scene. IMHO, it's the size and complexity of the variable's scope that affects whether it's OK to use $_ or whether you should use a named variable. Not the operations you do with the variable. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/