sub single_true { my $count = 0; $_ && $count++ foreach @_; return $count == 1; } if (single_true($x, $y, $z)) { ... }