Method #4 #!F:\Perl_program\perl\bin\perl -w #I am using Portable Strawberry PERL on Windows XP. use strict; use warnings; our $file1 = "F:/Perl_program/final2.csv"; our $file2 = "F:/Perl_program/HCDir2.csv"; our $fileOut = "F:/Perl_program/completed.csv"; our %file1Map = (); our %file2Map = (); open (FILE1, "completed.csv") or die("Could not open $fileout file."); foreach $fileout(){ (our $username2,our $dumour)=split('\n',$fileout); our $existingValue = $File1Map{"$username"}; our $newValue = $File2Map{"$fullname"}; if (! defined $existingValue){ $existingValue = ","; } if (! defined $newValue){ $newValue = "\n"; } print OUTFILE "" . $username2 . "," . $existingValue . "," . $newValue; } close (OUTFILE);