my $low = (keys %h)[0]; for( keys %h ) { if ($_ < $low ){ $low = $_; } } my $s_k = $low; my $s_v = $h{$low}; %h=(); $h{$s_k}=$s_v;