One could always just have another variable set to 1 (say $matched_already=1 )outside the first condition and then set to 0 if it passed into the initial unless block. A second unless in the chain would be considered only if:
unless { second_condition or $matched_already } { do_something_else}

and so on. . . Granted you won't get the nifty optimizations that come with the if/elsif/else structure where the subsequent elsif/else conditions are checked only if the previous if/elsif conditions all failed, but no extra parens. But for the same reasons you stated ..

Reversing the Real Stuff would mean changing ands to ors and inverting whatever, and is easy to mess up

, I think the elsunless would be another layer of complexity that I for one would have to stop the flow of code flowing from the fingers to grab a piece of paper to be able to gather figure what exactly I was excluding in every case, in all but the simplest cases where I would have used the unless/else or if/elsif/else structure anyhow. Then again at the moment I am hard pressed to think of one instance (I have pondered this for a couple of hours already), where an unless/elsunless/else structure would be more natural than its if/elsif/else counterpart. (though, I guess like most logic is a subjective matter)

-enlil


In reply to Re: Re: Re: if/unless and chaining by Enlil
in thread if/unless and chaining by John M. Dlugosz

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.