perl -wle' use Benchmark; my $max = $ARGV[0]; timethese($ARGV[1]||-1, { for => sub { for (my $i=0;$i<$max;$i++) { 1 } }, foreach => sub { for my $i (0..$max-1) { 1 } }, } )' 10000 2000 Benchmark: timing 2000 iterations of for, foreach ... for: 8 wallclock secs ( 7.63 usr + 0.00 sys = 7.63 CPU) @ 262.12/s (n=2000) foreach: 5 wallclock secs ( 5.38 usr + 0.00 sys = 5.38 CPU) @ 371.75/s (n=2000)