- or download this
for (my $i = 0; $i < 1000000; $i += 2) {$sum += $i}
- or download this
for my $i (map {$_ * 2} 0 .. 1000000 / 2) {$sum += $i}
- or download this
{
my $i=0;
...
$i+=2;
}
}
- or download this
use strict;
use Benchmark qw(cmpthese);
...
Rate for(;;) foreach
for(;;) 85.3/s -- -40%
foreach 143/s 68% --