$ perl -le ' > %h = ( one => 1, two => 1, three => 1 ); > $inv = do{ local $" = q{|}; qr{^@{ [ qw{ two three } ] }$} }; > map $h{ $_ } = 0, grep ! /$inv/, keys %h; > print qq{$_ - $h{ $_ }} for keys %h;' three - 1 one - 0 two - 1 $