use strict; use warnings; use Benchmark; sub perlish_for { my $iterator = 0; my $array_ref = [1 .. 10000]; for(@$array_ref) { $iterator++; } } sub cish_for { my $iterator = 0; my $array_ref = [1 .. 10000]; for(my $i=0; $_ = $array_ref->[$i] ;$i++) { $iterator++; } } my $count = 1000; timethese( $count, { 'Perlish' => \&perlish_for, 'C-ish' => \&cish_for } ); __OUTPUT__ Benchmark: timing 1000 iterations of C-ish, Perlish... C-ish: 9 wallclock secs ( 8.42 usr + 0.02 sys = 8.44 CPU) @ 118.46/s (n=1000) Perlish: 7 wallclock secs ( 6.67 usr + 0.06 sys = 6.73 CPU) @ 148.61/s (n=1000)