); sub original_get_proparg { my $propstr = shift; my $level = shift || 0; my $back = $propstr; my $cnt; if ($level == -1) { $propstr =~ /\(([^\(\)]+)\)+/; $propstr = $1; } else { for ($cnt = 0 ; $cnt < $level ; $cnt++) { $propstr =~ /\((.+)\)/; $propstr = $1; } } return $propstr; } use Benchmark; use Test::More qw(no_plan); use constant PROP => 'hello(what(is(this(all(about)))))'; use constant RANGE => -1 .. 5; my %expected = map +($_ => original_get_proparg(PROP, $_)), RANGE; for my $author (keys %get_prop_str) { is($get_prop_str{$author}->(PROP, $_), $expected{$_}, "by $author for case $_") for RANGE; } Benchmark::cmpthese(-2, { map { my $func = $get_prop_str{$_}; $_ => sub { $func->(PROP, $_) for RANGE }; } keys %get_prop_str }); __END__