# Perl's regex engine has its own defences against this shape of pattern:
# 5000 a's finish at once here too.
use strict;
use warnings;

my $input = ("a" x 5000) . "b";
my $started = time;
my $verdict = $input =~ /^(a|a)*$/ ? "match" : "no match";
my $speed = time - $started <= 1 ? "within a second" : "slowly";
print "  (\"a\" x 5000) . \"b\" =~ /^(a|a)*\$/   $verdict, $speed\n";
