in reply to How to join values of the same key that is an array of hashes?

use warnings; use strict; my %data; while (<DATA>) { my @cols = split; push @{ $data{$cols[0]} }, {$cols[1] => $cols[2]}; } for (sort keys %data) { my @ks; my @vs; for my $href (@{ $data{$_} }) { push @ks, keys %{ $href }; push @vs, values %{ $href }; } print "$_ ", join(',', @ks), " ", join(',', @vs), "\n"; } __DATA__ p1 cis 10 p1 plat 20 p1 gls NA p2 cis 0 p2 NA 9
  • Comment on Re: How to join values of the same key that is an array of hashes?
  • Download Code