use List::Util qw[ min ]; %h = map{ $_, $h{ $_ } } min keys %h;