unless ( (!($args =~ /\-rs(\s+)(\S+)/)) && (!($args =~ /\-p(\s+)(\S+)/)) && (!($args =~ /\-P(\s+)(\S+)/)) ) {..... # I figure this is easier to understand: unless ( $args =~ /\-rs(\s+)(\S+)/ or $args =~ /\-p(\s+)(\S+)/ or $args =~ /\-P(\s+)(\S+)/ ) {....

I agree the second form is easier to understand, but it's also not equivalent to the first:

c:\@Work\Perl\monks>perl -wMstrict -le "for my $s (qw(p X)) { printf qq{for '$s' case }; unless ( (!($s =~ /p/)) && (!($s =~ /q/)) && (!($s =~ /r/)) ) { pri +nt 'A' } unless ( $s =~ /p/ or $s =~ /q/ or $s =~ /r/ ) { pri +nt 'B' } } " for 'p' case A for 'X' case B
My understanding of haukex's point here is that the two if/unless-statement syntaxes that ovedpo15 was worried about are exactly equivalent, and so the condition expression doesn't have to change at all.

If I had written the original code, I think I would have written something very much along the lines you and GrandFather suggest (or like this). But if the original condition expression was correct, convoluted as it was, and did not have to change, I would say it was the better part of wisdom to just leave it alone.

I don't think we're really very far part on this one. :)


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


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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.