in reply to Re: Matching two files based on one column common in each
in thread Matching two files based on one column common in each

Hi Marshall,

Thanks for the code. I did changed the code a bit to make it work. Now, I am getting the correct output file.

while (my $row = $csv->getline($FILE1)) { # $row is a reference to a row my @fields = @$row; # this explicitly de-references my $id1 = $fields[1]; if (exists $file2{$id1}) { my $fields_ref= \@fields; unshift(@$fields_ref, "HK"); $csv->print ($FILE3, $fields_ref); # $csv->print ($FILE3, "HK", @fields); #both files } else { my $fields_ref = \@fields; unshift (@$fields_ref, "NOT_HK"); $csv->print ($FILE3, $fields_ref); } }