my %races; $races{$_} = 1 for $player_one_race, $player_two_race; if ($races{zerg} && $races{terran}) { ... }