in reply to How to join values of the same key that is an array of hashes?
Or this:
use warnings; use strict; my %h; while (<DATA>) { my @cols = split; push @{ $h{ shift @cols } }, \@cols; } print $_, ' ', join( ' ' => map { $_->[0] } @{ $h{$_} } ), ' ', join( ' ' => map { $_->[1] } @{ $h{$_} } ), $/ for sort { $a cmp $b } keys %h; __DATA__ p1 cis 10 p1 plat 20 p1 gls NA p2 cis 0 p2 NA 9
|
---|
In Section
Seekers of Perl Wisdom