# If your $key is *not* what we're looking for, remove i +t from the hash if ( !grep ($key, @keysToKeep) ) #### DB<137> 1 ~~ [1,2,3] => 1 DB<138> "a" ~~ [1,2,3] => "" DB<139> "4" ~~ [1,2,3] => "" DB<140> "2" ~~ [1,2,3] => 1 #### DB<145> %h=(a=>1,b=>2,c=>3) => ("a", 1, "b", 2, "c", 3) DB<146> @keysToDelete=qw/b c d/ => ("b", "c", "d") DB<147> delete @h{@keysToDelete} => (2, 3, undef) DB<148> \%h => { a => 1 } #### DB<153> %h=(a=>1,b=>2,c=>3) => ("a", 1, "b", 2, "c", 3) DB<154> @keysToKeep=qw/a e/ => ("a", "e") DB<155> %h2=() DB<156> @h2{@keysToKeep}=@h{@keysToKeep} => (1, undef) DB<157> \%h2 => { a => 1, e => undef }