use Benchmark qw(cmpthese); sub with_hash { my ($one, $two) = @{$_[0]}{'one', 'two'}; } sub wo_hash { my ($one, $two) = @{{@_}}{'one', 'two'}; } my %h = (one => undef, two => undef); cmpthese(1000000, { wo_hash => sub { wo_hash(one => 7, two => 9) }, with_hash => sub { with_hash({one => 7, two => 9}) }, with_consthash => sub { with_hash(\%h) }, with_consthash_mod => sub { @h{'one','two'} = (8,1); with_hash(\%h) }, with_consthash_modd => sub { @h{'one','two'} = (8,1); with_hash(\%h); @h{'one','two'}=() }, with_consthash_moddL => sub { local @h{'one','two'} = (8,1); with_hash(\%h);}, with_consthash_moddRA => sub { @h{'one','two'} = (8,1); my @r=with_hash(\%h); @h{'one','two'}=(); @r }, with_consthash_moddRS => sub { @h{'one','two'} = (8,1); my $r=with_hash(\%h); @h{'one','two'}=(); $r }, });