I think we're actually on the same page here. In my mind, $color is "this thing" and $_ is e.g. "blue".
But "for" topicalizes. $_ is the topic. $_ is more variable than $color, $_ is the thing.
for (qw/green blue red/) {
if ($color eq $_) { ... }
}
for each of green, blue and red:
if the color is it, do something
for (qw/green blue red/) {
if ($_ eq $color) { ... }
}
for each of green, blue and red:
if it is the color, do something
I read $_ as "the thing" or "it". How do you read $_?
Juerd
- http://juerd.nl/
- spamcollector_perlmonks@juerd.nl (do not use).
|