note
jethro
<p>Your first script uses a very convoluted way to construct the output. You use arrays to store simple scalar variables. You use loops where only a single value is concerned. You process the CSV file line by line, but somehow seem to think that you process a whole column at a time.</p>
<c>
#loop from your first script:
while ( my $hr = $csv->getline_hr( *DATA ) ) {
my $nr = $hr->{'ID'};
$nr=~ s/12/Sun/; # neither the g nor the loop are necessary
$nr=~ s/17/Moon/;
my $name = $hr->{'NAME'}; # only one value in column NAME of this line
my $ind = $hr->{'INDICATOR'};
my $val = $hr->{'VALUE'};
my $low = $hr->{'CI_LOW'};
my $high = $hr->{'CI_HIGH'};
if ($csv->combine ( $nr, $name, $ind, $val, $low, $high)) {
print $csv->string, "\n";
}
else {
print "combine () failed on argument: ",
$csv->error_input, "\n";
}
}
</c>
<p>Likewise "<c>$hr->{'ID'}=~ s/12/Sun/;</c>" could be used in your second script and the print adapted like Tux suggested </p>
937023
937023