in reply to Re^8: regex return true instead of false (precedence)
in thread regex return true instead of false

When I first encountered unless in Perl I thought it was pretty cool. However in practise I'm much more used to plain ol' if and I find unless slows down comprehension of code so I hardly ever use unless. I never use negated expressions or expressions with more than one term with unless - that is just too mind bendy.

I'd be strongly inclined to refactor the OP's condition to be like the version I used just to make the code easier to understand and maintain. In my view it is almost always worth taking the time to simplify convoluted code. And yes, putting the alternates in the regex is a completely acceptable solution.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Replies are listed 'Best First'.
Re^10: regex return true instead of false (precedence)
by AnomalousMonk (Archbishop) on Aug 27, 2019 at 14:27 UTC
    ... I hardly ever use unless. I never use negated expressions or expressions with more than one term with unless ...

    That tends to be my practice. I will quite often use a statement like
        next LOOP unlessX;
    for loop control where X is a fairly simple condition expression; otherwise, I agree that unless (and his scruffy pal until) are just too mind-bendy. (I think I remember TheDamian recommending this practice in his PBP.)


    Give a man a fish:  <%-{-{-{-<