in reply to Difference between for and foreach

Time to revisit for vs foreach from the year 2000.

perlsyn says:

The foreach keyword is actually a synonym for the for keyword, so you can use foreach for readability or for for brevity.
Update: I now see the link to for vs foreach was already mentioned by n8g above.
--
Andreas

Replies are listed 'Best First'.
Re^2: Difference between for and foreach
by skaurus (Novice) on Jun 13, 2013 at 18:40 UTC
    What about this bit then?

    And it's faster because Perl executes a foreach statement more rapidly than it would the equivalent for loop.

      That comment is about the C-style for loops ( e.g. for ( $i = 0; $i < $j; $i++) versus iterating directly over a list ( e.g. for my $item (@array)).
        Thanks! I expected a notification email, didn't received one and because of this I saw your answer just now.
      Regarding the context, I would say "the equivalen for loop" means the C-style loop. The documentation should probably be improved there.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        Thanks!