in reply to
Re: Pattern matching across two files, Need something better than grep -f!
in thread Pattern matching across two files, Need something better than grep -f!
A little bit faster:
use strict;
use warnings;
open my $data_fh, '<', "data" or die $!;
open my $patern_fh, '<', "pattern.txt" or die $!;
my %patterns;
while (<$patern_fh>) {
$patterns{join $;, split} = ();
}
close $patern_fh;
{
local $, = "\t";
local $\ = "\n";
while (<$data_fh>) {
my @line = split;
if (exists $patterns{$line[0] . $; . $line[1]}) {
print @line[0, 1, 3];
}
}
}
close $data_fh;