in reply to Underscore _ prototype in 5.10
for (qw(The quick brown fox)) { s/o/u/g; }
This doesn't produce any warning, but has side-effects. (I think. I can't remember the circumstances.)
for (1..5) { $_ = ...; }
You need to make a copy of the constants to modify them.
for (map "$_", qw(The quick brown fox)) { s/o/u/g; }
for (qw(The quick brown fox)) { my $s = $_; $s =~ s/o/u/g; }
for (qw(The quick brown fox)) { for (my $s = $_) { s/o/u/g; } }
Update: Fixed a copy and paste error. The first two snippets were identical.
|
|---|