in reply to back iffing with for?

Didn't this issue just come up recently?

Replies are listed 'Best First'.
Re^2: back iffing with for?
by ikegami (Patriarch) on Apr 06, 2005 at 04:31 UTC
    No, that for loops and foreach loops are distinct has no bearing on whether either or both can be used as a statement modifier. for loops cannot. foreach loops can, but only if no index variable is specified.
      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.

      Perhaps I should have linked to the whole thread, and not merlyn's recent post about the for and foreach distinction.

      Although the keywords may be replaced, the two have distinctly differeny syntax (which the original poster's example shows). The end result is that the two are not completely interchangable.