my $low_key = (keys %h)[0]; for my $k ( keys %h ) { $low_key = $k if ($k < $low_key ); } my $val_l_k = $h{$low_key}; %h=(); $h{$low_key}=$val_l_k;