use strict; use warnings; my %some_hash = ( sunny => .63, cloudy => .17, rainy => .2 ); my @key_list = keys %some_hash; my $max_key = pop @key_list; foreach (@key_list) { $max_key = $_ if $some_hash{$_} > $some_hash{$max_key}; } print $max_key." :: ".$some_hash{$max_key}."\n";
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
In reply to Re: max key-value pair in a hash
by CountZero
in thread max key-value pair in a hash
by kettle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |