#!/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() { my($var1, $var2, $var3,$var4,$var5)=split(/\t/, $_); while() { my($id1, $id2,$id3)=split(/\t/,$_); while() { 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); #### new_id county_name1 county_id1 routing_number city_code1 56897987 Smith 865487 567rt9834 5879654 65798686 Johnson 6587654 6578ce789 r6587t3 24598702 Rock 6548365 6456t6884 z0rt345 #### Old_id state_code2 fip_code 865487234 5679834 5879654 6587654098 6578789 43658753 6548365tr 6456884 50054345 #### city_code3 state_code3 zip_code3 5879654 5679834 987656575 r658735 6578789 657656315 z0r3454 6456884 554865434 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

after running the script I do not get the value of "Old_id" and "city_code3"

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