in reply to Parsing Large Text Files For Performance
Using the index function along with getting rid of IF cases early has definitely sped things up considerably. Thoughts?my $hdr_search = qr{^\-{4}\s\d}; sub useIndex { my ($ip1, $ip2, $lines) = @_; for my $line (@$lines) { unless (($line =~ $hdr_search) || ($header)) { next; } unless ($line =~ $hdr_search) { print $line; ## Print matching packet body next; } if (0 > index ($line, $ip1) || (0 > index ($line, $ip2))) { $header = 0; next; } else { print "\n$line"; ## Print matching packet header $header = 1; } } }
|
|---|