in reply to max "value " of an hash
List::Util::reduce() is very useful for this:
use List::Util qw[ shuffle reduce ];; my %hash; @hash{ 'a'..'z' } = shuffle 1 .. 26;; my $maxKey = reduce{ $hash{ $a } > $hash{ $b } ? $a : $b } keys %hash; +; print "$maxKey : ", $hash{ $maxKey };; x : 26
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: max "value " of an hash
by Aaronrp (Scribe) on Jan 18, 2011 at 19:11 UTC |