use Benchmark qw/ cmpthese /; my $x = 42.0; my $y = "$x"; my $p = pack 'F', $x; my (%h1,%h2,%h3,%h4); cmpthese( -1, { F => sub { $h1{ pack 'F', $x } = 1 }, s => sub { $h2{ $x } = 1 }, y => sub { $h3{ $y } = 1 }, p => sub { $h4{ $p } = 1 }, }); __END__ Rate s F p y s 4032984/s -- -64% -84% -84% F 11327209/s 181% -- -54% -56% p 24707825/s 513% 118% -- -5% y 25997751/s 545% 130% 5% --