![]() |
Compare common fields from two text files
Hi guys, Perl newbie here. Need help here. I've got two text file - File1.txt and File2.txt. The files consist of :
File1.txt Field1 Field2 Field3 Field4 Field5 A 1 1 1 A1 B 2 2 2 B2 C 3 3 3 C3 D 4 4 4 D4 E 5 5 5 E5 F 6 6 6 F6 File2.txt Field2 Field3 Field4 1 1 1 2 2 2 3 3 3 I want to check both files, and if both have the same values for Field2,Field3,Field4 - in this example, the output should be the lines from File1.txt A 1 1 1 A1 B 2 2 2 B2 C 3 3 3 C3 It should do checking by line to whole file rather than line1 compare line1, line2 compare line2, etc. Meaning it should be something like this : Line1(File1.txt) compare all contents of File2.txt, print line from File1.txt with common values Line2(File1.txt) compare all contents of File2.txt, print line from File1.txt with common values Line3(File1.txt) compare all contents of File2.txt, print line from File1.txt with common values and not : Line1(File1.txt) compare Line1(File2.txt), print line from File1.txt if have common values Line2(File1.txt) compare Line2(File2.txt), print line from File1.txt if have common values Line3(File1.txt) compare Line3(File2.txt), print line from File1.txt if have common values Here's my code but I"m not too sure what's wrong as I'm seem to have the wrong output. Code:
|
Re: Compare common fields from two text files
Here's it
Code: Perl
|
| All times are GMT +5.5. The time now is 17:52. |