in reply to Testing multiple variables against the same criteria (IF statement)
What i'm after is a shorter way to test whether any of those variables == 1.
If by shorter you mean "golfed down", i.e. achieving the same with less characters typed - it is up to you to be smart, go ahead, be clever.. but if by shorter you mean less convoluted, I'd propose to wrap the test into a loop which aliases each var, more so if there's a variable amount of many variables to test, and it is possible to wrap them into an array (which should be possible but in very weird cases):
$test_succeeded = 0; for(@vars_to_test) { 1 == $_ and ++$test_succeeded and last; } if ($test_succeeded) { ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Testing multiple variables against the same criteria (IF statement)
by AnomalousMonk (Archbishop) on Sep 05, 2016 at 22:44 UTC |