use strict; use warnings; use Benchmark qw(cmpthese); cmpthese(-10, { 'anon' => sub { for my $x (qw(a b a b a b)) { my $y = { 'a' => 'A', 'b' => 'B'}->{$x}; }}, 'named' => sub { for my $x (qw(a b a b a b)) { my $h = { 'a' => 'A', 'b' => 'B'}; my $y = $h->{$x}; }}, });