#!/usr/bin/perl

use strict;
use warnings;

if($#ARGV != 2 ) {
		print "usage: efficient_reverse_grep.pl term_file search_file output_file\n";
		exit;
}

my $in_file = $ARGV[0];
my $search_file = $ARGV[1];
my $out_file = $ARGV[2];

my %in_hash;

open(INFILE,"$in_file");

while(<INFILE>) {
		my $line = $_;
		chomp $line;
		$in_hash{$line} = $line;
}
close(INFILE);

open(SEARCHFILE,"$search_file");
open(OUTFILE, ">$out_file");

while(<SEARCHFILE>) {
		my $line = $_;
		chomp $line;
		if(!defined($in_hash{$line})) {
				print OUTFILE "$line\n";
		}
}

