Don't assign to a global variable without localising it. You just clobbered your parent's data.Of course, the parent could protect its $_ my using a lexical variable. And so can do_stuff1. local $_ is in idiom I've had no need for the past 2 years.
You also wrote:sub do_stuff1 { my $_ = shift; chomp; say; }
or even safer:Safer? You should test your code if you label it 'safe', or 'safer'. I guess you didn't realize that local *_; also gives you a new value for @_, so you no longer have access to the subs parameters?sub do_stuff1 { local *_; $_ = shift; ... }
In reply to Re^2: style guidance
by JavaFan
in thread style guidance
by 7stud
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |