in reply to style guidance
or even safer:sub do_stuff1 { local $_ = shift; chomp; say; }
sub do_stuff1 { ${ local *_ } = shift; chomp; say; }
The latter handles the case where $_ is tied or otherwise magical. For example, $_ is magical if the parent does
orfor (..., $tied, ...) { ... do_stuff1(...); ... }
for (..., substr($s, ...), ...) { ... do_stuff1(...); ... }
You've ended up complicating things instead of simplifying them. It's best not to use $_ here.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: style guidance
by JavaFan (Canon) on Nov 08, 2009 at 00:53 UTC | |
by ikegami (Patriarch) on Nov 08, 2009 at 01:56 UTC | |
|
Re^2: style guidance
by 7stud (Deacon) on Nov 09, 2009 at 00:02 UTC | |
by ikegami (Patriarch) on Nov 09, 2009 at 19:57 UTC |