foreach my $id (sort keys %test) { next if not exist $test{$id}; print "$id :: $test{$id}\n"; delete $test{13}; }