http://www.perlmonks.org?node_id=377453


in reply to Re^2: map to hash of arrays
in thread map to hash of arrays

Use a while loop, not a map:
my %hash; my $key; while (<>) { /\S+ : (\S+)/ or die "unexpected line format: $_"; my $value = $1; if (defined $key) { push @{ $hash{$key} }, $value; undef $key; else { $key = $value; } }
--Dave
Opinions my own; statements of fact may be in error.