my %hash = (populated somehow); my ($victim_key, $victim_value); for (0..int rand (scalar keys %hash)) { ($victim_key, $victim_value) = each %hash; } scalar keys %hash; # reset the iterator