in reply to Unique keys for multiple values with a Hash
use strict; my %hash = (); my ($first, $second); while (<DATA>) { ($first, $second) = split; push (@{$hash{$first}}, $second); # from Perl Cookbook 5.7 } while ((my $key, my $value) = each %hash) { print "the Key is: $key\n"; print join("\n",@$value),"\n\n"; } __END__ 5 25 6 27 5 24 5 23 6 29 6 30 4 22 5 25 6 27 4 22 4 21
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Unique keys for multiple values with a Hash
by Anonymous Monk on Jan 14, 2003 at 19:18 UTC | |
by tall_man (Parson) on Jan 14, 2003 at 19:28 UTC |