Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
foreach (@a) { $hash{$a}++; }
@key = keys %hash;
foreach (@key) { print "$_ found $hash{$_} times\n";}
Question: How can I populate the hash without a loop? @hash{@a} = (1) x @a;
doesnt really work to create a count of duplicate hash items.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How can I populate a hash?
by trammell (Priest) on Jan 25, 2005 at 22:31 UTC | |
|
Re: How can I populate a hash?
by jdporter (Paladin) on Jan 25, 2005 at 22:35 UTC | |
|
Re: How can I populate a hash?
by Aristotle (Chancellor) on Jan 25, 2005 at 22:30 UTC | |
by chromatic (Archbishop) on Jan 26, 2005 at 00:24 UTC | |
by Aristotle (Chancellor) on Jan 26, 2005 at 02:25 UTC | |
|
Re: How can I populate a hash?
by Fletch (Bishop) on Jan 25, 2005 at 22:12 UTC | |
by friedo (Prior) on Jan 25, 2005 at 22:14 UTC |