use Benchmark 'timethese'; $x = int (1_000_000 * rand 1_000_000); timethese(-5, { multiple => sub { $x =~ /(\d)*(\d)/ }, backtrack_c => sub { $x =~ /(\d*)(\d)/ }, backtrack => sub { $x =~ /\d*(\d)/ }, opt => sub { $x =~ /(\d)$/ }, mod => sub { $x % 10 }, });