my @valid = qw( this that another ); my %valid = map { $_ => 1 } @valid; $broken->{$_} = 0 for @valid; $broken->{$_} = 1 for grep $valid{$_}, @list;