#!/usr/bin/perl use warnings; use strict; use Benchmark qw(:all); my ( %hn, %hc ); @hn{ 0 .. 9 } = @hc{ 'a' .. 'j' } = 0 .. 9; cmpthese( timethese( shift || 10_000_000, { numD => sub { return $hn{9} }, numQ => sub { return $hn{'9'} }, chrD => sub { return $hc{j} }, chrQ => sub { return $hc{'j'} }, } ) );