if((grep { $_ } $x, $y, $z) == 1) { print "Exactly one variable set\n"; }