in reply to Re: "$_" vs. $_
in thread "$_" vs. $_
So I would say that any code that *sets* $_ is, by definition, wrong.Unnecessary, perhaps, but not wrong. Setting $_ can be useful:
Instead of this:
You can write this:$h->{foo}{bar} =~ s/[._]/ /g; Some::Custom::Function($h->{foo}{bar}); $h->{foo}{bar} =~ s/^\s+//; $h->{foo}{bar} =~ s/\s+$//; $h->{foo}{bar} =~ s/`/'/g;
for ($h->{foo}{bar}) { s/[._]/ /g; Some::Custom::Function($_); s/^\s+//; s/\s+$//; s/`/'/g; };
map { $_ = foo( $bar, $_ ) } values %somehash;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: "$_" vs. $_
by Beechbone (Friar) on Apr 10, 2007 at 14:31 UTC | |
by mrpeabody (Friar) on Apr 10, 2007 at 19:47 UTC |