About how I use conditionals?

In perl I mostly use and and or for conditionals much more often than if and unless.

I never use prefix unless. I very rarely use postfix unless, only in cases when the condition almost always holds, like print ", " unless $index==$length-1;

I use prefix if for conditionals that have both a then and an else (or elsif) branch. I sometimes use prefix if for other conditionals randomly, especially when there is no action done in the condition. I sometimes use postfix if in similar cases, when the condition is not very important.

But for most conditionals, I just use and, or, or with multiple statements and do {, or do {. That is good because it places emphasis on the condition.

This is only my coding style in perl, it's of course different in other languages as their conditional constructs are different too.


In reply to Re: A new idiom -or- I Hate Unless by ambrus
in thread A new idiom -or- I Hate Unless by erikharrison

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.