$excludeaccts = "accts_to_exclude.txt"; Open(FILEHANDLE, $excludeaccts) || die ("Cannot open $excludeaccts"); %lookup = map {chomp; $_ => undef} ; close(FILEHANDLE); $origlist = "orig_accts.txt"; open(ACCTLISTFILE, $origlist) || die ("Cannot open orig_accts.txt"); open($output, '>', 'output.txt') || die ("Cannot open output file output.txt"); while ($line = ){ chomp $line; ($filename, $state, $amt, $ttl, $account, $name, $invnum) = split /\t/, $line; next if exists $lookup{$account}; print $output "$filename $state $amt $ttl $account $name $invnum\n"; }