Rate Map Foreach Map 21.9/s -- -43% Foreach 38.6/s 76% -- #### use strict; use Benchmark (); Benchmark::cmpthese(-10, { "Map" => sub { my %hash = map{$_=>1} (1..10000); }, "Foreach" => sub { my %hash; $hash{$_} = 1 foreach (1..10000); }, "Map-like" => sub { my @a; push(@a, $_, 1) foreach (1..10000); my %hash = @a; }, }) __END__ Rate Map-like Map Foreach Map-like 21.5/s -- -1% -44% Map 21.8/s 1% -- -43% Foreach 38.6/s 80% 77% --