use warnings; use strict; use Benchmark; open my $fh, '<', 'in.txt' or die $!; timethese(1000000, { regex => '_regex', split => '_split', }); sub _regex { seek $fh, 0, 0; while (<$fh>){ if (/^\d+\.\s+(?:N\/A\s+|\d+\s+){2}(\w+)/){ #print "$1\n"; } } } sub _split { seek $fh, 0, 0; LINE: while (<$fh>){ my ($x, $one, $two, $test_name, @remaining) = split; for ($one, $two){ next LINE unless $_ eq 'N/A' or $_ =~ /^\d+$/; #print "$test_name\n"; } } } __END__ Benchmark: timing 1000000 iterations of regex, split... regex: 20 wallclock secs (17.97 usr + 3.04 sys = 21.01 CPU) @ 47596.38/s (n=1000000) split: 39 wallclock secs (35.57 usr + 3.35 sys = 38.92 CPU) @ 25693.73/s (n=1000000)