my $first = 1; for my $n (sort { $hash{$a} <=> $hash{$b} } keys %hash){ if ($first) { $first = 0; next; } ... }