in reply to How can I group lines in a file?
There's nothing wrong with the other solutions offered, but it can be done more concisely with no loss of clarity:
my %HoA; ## Typo corrected open my $fh, '<', 'junk.dat' or die $!; /(\S+)\s+(\S+)/ and push @{ $HoA{ $1 } }, $2 while <$fh>; close $fh; pp \%HoA; { ernest => [38, 27], jim => [14, 34], john => [23, 44], matilda => [43, 22] }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can I group lines in a file?
by bichonfrise74 (Vicar) on May 17, 2009 at 02:39 UTC | |
by Anonymous Monk on May 17, 2009 at 04:31 UTC | |
by Anonymous Monk on May 17, 2009 at 04:32 UTC | |
by bichonfrise74 (Vicar) on May 17, 2009 at 06:05 UTC | |
by BrowserUk (Patriarch) on May 17, 2009 at 07:00 UTC | |
|
Re^2: How can I group lines in a file?
by akho (Hermit) on May 17, 2009 at 13:37 UTC | |
by BrowserUk (Patriarch) on May 17, 2009 at 16:28 UTC | |
by akho (Hermit) on May 17, 2009 at 19:44 UTC | |
by BrowserUk (Patriarch) on May 17, 2009 at 22:40 UTC |