↓Perlのパターンマッチに異常に時間がかかる例
#!/usr/bin/perl
my $num = 30;
my $str = "a" x $num;
my $pattern = "a?" x $num . $str;
sub perl { print "${str}\n" if ($str =~ m{$pattern}); }
sub egrep { system "echo ${str} | egrep ${pattern}"; }
sub awk { system "echo ${str} | awk /${pattern}/"; }
print "matching ${str}\n";
print "against pattern ${pattern}\n\n";
print "with egrep\n"; egrep();
print "with awk\n"; awk();
print "with perl\n"; perl();