Just to (perhaps) clarify, people (including the perl documentation) often use for to mean the c-style loop:
for ($he="s"; $a<$jolly; $good+=$fellow) { ... }
and foreach to mean the more commonly used iterate-over-a-list loop:
foreach my $country (qw/I give a fig/) { ... }
but really "for" and "foreach" are interchangable; both keywords can be used for both types of loops.
And, people being people, those who know this tend to use the shorter "for" exclusively, which creates a disjunction with how other people refer to the two loop styles. I much prefer to just say C-style for and regular (or no adjective at all) for. |