I want to join 2 files on matching keys ( column 1 in both files ) and check for unmatched columns, If for each record print the first unmatched column from both files and then proceed to next record and do the same.
Hi, perhaps you need to switch the reading order of $File1 and $File2 ?
Did you inititialize the shell variables correctly?
I am unsure what you mean by "I couldn't get to stop processing after first mismatched column for each record""
open FH,"<1.txt";
while(<FH>){
chomp;
my @tmp = split("[|]",$_);
$hash{$tmp[0]}=[@tmp[1..$#tmp]];
}
LEO:
while(<DATA>){
chomp;
my @tmp = split("[|]",$_);
my @pre=@{$hash{$tmp[0]}};
my @cur=@tmp[1..$#tmp];
for (my $i=0;$i<=$#pre;$i++){
if($pre[$i] ne $cur[$i]){
print $tmp[0]," ",$pre[$i]," ",$cur[$i],"\n";
next LEO;
}
}
}
__DATA__
123|Roy|jj|20/07/3000|25.48
125|Victor|kk|30/07/2009|34.56
234|Nag|aa|15/03/2009|234.45