use strict; use warnings; use Benchmark; my @a; $a[$_] = int( rand(100) ) for ( 0 .. 10000000 ); cmpthese( -30, { 'foreach' => sub { foreach (@a) { $_ += 1; } }, 'map (assign)' => sub { @a = map { $_ += 1 } @a; }, 'map (bare)' => sub { map { $_ += 1 } @a; }, } );