Regular expressions are attractive for this sort of problem, because they can express a number of constraints in a single pattern. In this case a regexp such as /[06]/ is slightly slower than the two numerical tests (at least on my local perl installation), but we're talking fractions of a microsecond, and the OP gives no reason to assume that speed is a concern.
More relevant is what will make the code easier to read and maintain, and that usually means making the code reflect the reality behind the check as expressively as possible. Accordingly, I'd be tempted to write something like:
.. but that might be overkill. :)use constant SATURDAY => 6; use constant SUNDAY => 0; if ($day != SATURDAY && $day != SUNDAY) { ... }
Hugo
In reply to Re^2: Short or Long Hand
by hv
in thread Short or Long Hand
by Scarborough
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |