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.
Opinions my own; statements of fact may be in error.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: map to hash of arrays
by emilford (Friar) on Jul 27, 2004 at 13:53 UTC | |
by dpuu (Chaplain) on Jul 27, 2004 at 16:26 UTC | |
by emilford (Friar) on Jul 27, 2004 at 21:42 UTC |
In Section
Seekers of Perl Wisdom