my %unwanted = map { $_ => 1 } @unwanted; my @wanted = grep !$unwanted{ $_ }, keys %hash; my %subhash = %hash{ @wanted }; do_something( \%sub_hash );