in reply to for loop syntax difference

Here is a quote from the official Perl documentation (For Loops):
And it's faster because Perl executes a foreach statement more rapidly than it would the equivalent for loop.
I believe the "for" in the docs refers to a C-style loop (for($i=0;$i<10;$i++)) and the "foreach" refers to the more Perlish style (for $i (1..10)).

To prove that it is faster for you, you would have to benchmark it, as someone else already explained to you in another forum. It is considered good etiquette to mention that you already asked this question elsewhere.

Replies are listed 'Best First'.
Re^2: for loop syntax difference
by Taulmarill (Deacon) on Aug 28, 2009 at 14:05 UTC
    I believe the "for" in the docs refers to a C-style loop (for($i=0;$i<10;$i++)) and the "foreach" refers to the more Perlish style (for $i (1..10)).

    Yes, however for and foreach are interchangeable since perl automatically detects which one to use.
      Also from the official Perl documentation (For Loops):
      The foreach keyword is actually a synonym for the for keyword, so you can use foreach for readability or for for brevity.