use Benchmark qw(cmpthese); my $f = '-f'; my $f2 = '-field'; cmpthese( 500000, { 'ng_short' => sub { $f =~ /^-f(i(e(ld??)??)??)??$/ }, 'ng_long' => sub { $f2 =~ /^-f(i(e(ld??)??)??)??$/ }, 'g_short' => sub { $f =~ /^-f(i(e(ld?)?)?)?$/ }, 'g_long' => sub { $f2 =~ /^-f(i(e(ld?)?)?)?$/ }, } ); # Rate ng_long g_long g_short ng_short # ng_long 88339/s -- -54% -73% -74% # g_long 193798/s 119% -- -41% -42% # g_short 328947/s 272% 70% -- -2% # ng_short 335570/s 280% 73% 2% --