That last loop obviously is wrong. You cannot loop over a file handle. Certainly not over one that has been read to the end. Compare to below example and work out what you want exactly yourself
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" the
+re!
}
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;
Enjoy, Have FUN! H.Merijn
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|