for my $k (grep { defined } delete $hash{Foo}, keys %hash) { # ... do stuff here }