use strict; use warnings; use Benchmark qw( cmpthese ); use constant { MATCHES => 6, POWER => 14, }; my @orig = ( qr/.*Error.*/, qr/.*error.*/, qr/.*ERROR.*/, qr/.*FATAL.*/, qr/.*Critical.*/, qr/.*exception.*/, ); my @new = ( qr/Error/, qr/error/, qr/ERROR/, qr/FATAL/, qr/Critical/, qr/exception/, ); my $total = MATCHES * (2 ** POWER); my @lines = ; push @lines, @lines for 1 .. POWER; cmpthese ( 10, { orig => sub { find(\@orig, \@lines) }, new => sub { find(\@new, \@lines) }, } ); sub find { my ($res, $lines) = @_; my $count = 0; for my $line (@$lines) { $line =~ /$_/ && ++$count for @$res; } $count == $total or die "Expected $total, counted $count"; } __DATA__ Line 1 This contains an Error: 1 Line 3 Line 4 This contains an error: 2 This contains an ERROR: 3 Line 7 FATAL (4) Line 9 This problem is Critical Line 11 exception