|Think about Loose Coupling|
Re^2: var comparisonby nemesisgus (Acolyte)
|on Sep 07, 2012 at 16:37 UTC||Need Help??|
There were no hidden intentions. My question was simply the product of my poor knowledge of Perl :^)
Although it's true that shorter doesn't always mean more efficient, it's also true that when you start with a language you tend to use long and complicated expressions to accomplish tasks that, once you have a little (or no so little) more knowledge, you realize that could have been done in a much shorter (and usually clearer) way.
I was just wondering if this was the case, so the expression:$var eq 'foo' || $var eq 'bar'
could be translated to something like:$var eq (foo|bar) (which, of course, does not work)
or similar, the same way the defined-or operator helps to turn $x = $x // 5 into $x //= 5, for instance.
(I understand that the implications of doing $var eq (foo|bar) would probably be more complex).
Consider also that the case I proposed had only two options to compare, so the first version is OK, but with more options a shorter manner would be appreciated. Since that seems not possible, a function would be the best solution as suggested by MidLifeXis.