in reply to Adding missing values into a hash
Hi,
in your inner loop you have to replace the last line
my ($string, $int) = (split(/\;/, $dat));
by the following
my @elements = split /;/, $data; my %rowvalues; foreach my $element (@elements) { my ($key, $value) = split /=/, $element; $rowvalues{$key} = $value; } foreach my $key (keys %info) { if(exists $rowvalue{$key}) { push @{$info{$key}}, $rowvalue{$key}; } else { push @{$info{$key}}, 'NA'; } }
I hope that is it. I haven't tested. Please put code tags around your sample data so we can see the structure better.
Regards
McA
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Adding missing values into a hash
by Biopolete (Initiate) on Jun 19, 2014 at 14:33 UTC | |
by Anonymous Monk on Jun 20, 2014 at 07:22 UTC | |
by Biopolete (Initiate) on Jun 20, 2014 at 12:22 UTC |