Please use ***
[code][/code] tags*** around your code and data, to preserve formatting and to improve readability. Please do
not use quote tags, colors, or other fancy formatting.
I'm not experienced in
perl, but assuming the input files aren't too large to keep in memory, here's how I'd do it in
awk. The concept should be transferable to other languages.
Code:
awk 'NR==FNR { arr[$1$2]=1 ; next } ( ! arr[$1$2] ){ print }' File2.txt File1.txt
1) Read file2 in a hash (assoc. array), with the index equal to field1+field2. The value only needs to be a positive string of some kind, as all we need to do is keep track of existing fields.
2) Iterate over file1, and if the first two fields fail to match an existing index, print the line. Otherwise ignore it.
Incidentally, if you aren't wedded to perl, and if the format is unique enough that a simple whole-line comparison can't result in false positives, then a simple
grep could also do the job:
Code:
grep -v -f File2.txt File1.txt