in reply to How to get the Max values' key!

One simple way of doing this is by sorting (by value) each sub-hash:

use strict; use warnings; my %r; $r{123}{a}=3; $r{123}{b}=2; $r{456}{c}=5; $r{456}{d}=7; for my $href (keys %r){ my $maxkey = (sort { $r{$href}->{$b} <=> $r{$href}->{$a} } keys %{$r +{$href}})[0]; print "\$r{$href}{$maxkey} ==> $r{$href}{$maxkey}\n"; }

Outputs the desired result:

$r{456}{d} ==> 7 $r{123}{a} ==> 3

Hope this helps

citromatik