#%hFirst stores lines loaded in from first file #%hSecond stores lines loaded in from second file #%hThird stores lines loaded in from third file #OUT is a file handle to your one and only output file while (my ($sKey, $fld1) = each(%hFirst)) { my $fld1 = $hFirst{$sKey}; my $fld2 = exists $hSecond{$sKey} ? $hSecond{$sKey} : "NOT DEFINED"; my $fld3 = exists $hThird{$sKey} ? $hThird{$sKey} : "NOT DEFINED"; print OUT "$fld1======$fld2======$fld3\n"; }