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