#!/usr/local/bin/perl use strict; open (FILE1,"Largedatafile.txt") || die "Can't open file File1 $!\n"; open (FILE2,"Smalldatafile.txt") || die "Can't open file File2 $!\n"; open (FILE3,"addressfile.txt") || die "Can't open file File3 $!\n"; while(<FILE2>) { my($var1, $var2, $var3,$var4,$var5)=split(/\t/, $_); while(<FILE1>) { my($id1, $id2,$id3)=split(/\t/,$_); while(<FILE3>) { my($citycode, $statecode,$zipcode)=split(/\t/,$_); if (($id3 ne $var3) and ($citycode ne $var5)) { print "$var1\t$id1\t$zipcode\n"; } } } } close (FILE1); close (FILE2); close (FILE3);
input file1 "Largedatafile.txt"
new_id county_name1 county_id1 routing_number city_cod +e1 56897987 Smith 865487 567rt9834 + 5879654 65798686 Johnson 6587654 6578ce789 + r6587t3 24598702 Rock 6548365 6456t6884 + z0rt345
input file2 "Smalldatafile.txt"
Old_id state_code2 fip_code 865487234 5679834 5879654 6587654098 6578789 43658753 6548365tr 6456884 50054345
input file3 "addressfile.txt"
city_code3 state_code3 zip_code3 5879654 5679834 987656575 r658735 6578789 657656315 z0r3454 6456884 554865434 </c <p> out put file will have new_id from file1, old_id from file2, and zip_code3 from file3 only if state_code2 from file2 not equal to state +_code3 from file3 and city_code3 from file 3 not equal to city_code1 +form file1 </p><p> after running the script I do not get the value of "Old_id" and "cit +y_code3" </p> <c> new_id Old_id zip_code3 new_id Old_id 987656575 new_id Old_id 657656315 new_id Old_id 554865434 new_id Old_id 987656575 new_id Old_id 657656315 new_id Old_id 554865434
20060712 Janitored by Corion: Added code tags, as per Writeup Formatting Tips and Writeup Formatting Tips
In reply to Re^2: Comparing text files
by lynxct
in thread Comparing text files
by lynxct
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |