use Benchmark(cmpthese); cmpthese(1000000, { 'a' => sub { $_ = '12-12-12-12-12'; undef $h{$1} while (s/(\d\d)//); }, 'b' => sub { $_ = '12-12-12-12-12'; undef $h{$1} while (m/(\d\d)/g); }, 'c' => sub { $_ = '12-12-12-12-12'; undef @h{m/\d\d/g}; } }); #### Rate a b c a 195427/s -- -19% -35% b 241896/s 24% -- -20% c 300933/s 54% 24% --