open my $fh1, "<", "final.csv" or die "final.csv: $!"; $csv->column_names ($csv->getline ($fh1)); # Read the header line while (my $row = $csv->getline_hr ($fh1)) { $File1Map{$row->{username}} = $row->{date_modified}; # NO "my" there! } open my $fh2, "<", "HCDir.csv" or die "HCDir.csv: $!"; $csv->column_names ($csv->getline ($fh2)); # Read the header line while (my $row = $csv->getline_hr ($fh2)){ $File2Map{$row->{fullname}} = $row->{branch}; # NO "my" there! } $csv->eol ("\n"); # Now use it for output open my $fh3, ">", "completed.csv" or die "completed.csv: $!"; $csv->print ($fh3, [qw( user date_modified branch )]); foreach my $user (sort keys %File1Map) { $csv->print ($fh3, [ $user, $File1Map{$user}, $File2Map{$user} || "?" ]); } close $fh3;