D
Dan Jacobson
This program does what I want, but is it a proper use of a hash of
hashes, etc.?
$ cat data
5a m g t
4g k x
5a t c
$ perl p.pl < data
4g: k x
5a: c g m t
$ cat p.pl
use strict;
use warnings;
my %k;
while (<>) {
my @F = split;
my $h = shift @F;
for (@F) { $k{$h}{$_} = undef }
}
for ( keys %k ) { printf "$_: %s\n", join " ", sort keys %{ $k{$_} } }
hashes, etc.?
$ cat data
5a m g t
4g k x
5a t c
$ perl p.pl < data
4g: k x
5a: c g m t
$ cat p.pl
use strict;
use warnings;
my %k;
while (<>) {
my @F = split;
my $h = shift @F;
for (@F) { $k{$h}{$_} = undef }
}
for ( keys %k ) { printf "$_: %s\n", join " ", sort keys %{ $k{$_} } }