Short circuiting should be avoided in perl, it has better faculties.

Tell that to the POD. The docs for open, for example, give at least a dozen examples of constructs similar to this:

open FH, '>', 'filename' or die $!;

...and who could argue that use of short circuiting is inferior to this:

die $! unless open FH, '>', 'filename';

This is further discussed in the following quote from perlstyle:

Here are some other more substantive style issues to think about:

  • Just because you CAN do something a particular way doesn't mean that you SHOULD do it that way. Perl is designed to give you several ways to do anything, so consider picking the most readable one. For instance

    open(FOO,$foo) || die "Can't open $foo: $!";

    is better than

    die "Can't open $foo: $!" unless open(FOO,$foo);

    because the second way hides the main point of the statement in a modifier.

The point here is that you cannot make a sweeping statement such as "short circuiting should be avoided in Perl". Avoided why? There are several equally efficient ways to do things. The docs are right: "consider picking the most readable one." You might be right that short circuiting hides the intent in this case, but certanly it's going too far to say it should be avoided altogether.


Dave


In reply to Re^2: One out of three ain't bad by davido
in thread One out of three ain't bad by saintmike

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.