I presume he was reacting to:

if (@ARGV) { if (@ARGV == 1) { Download($ARGV[0]); EXIT(0, 'SUCCESS. Argument was received from command line.'); } else { PrintUsage(); EXIT(-1, 'Argument missing.'); } } else { Download(GetArgs()); EXIT(0, 'SUCCESS. Argument was received from stdin.'); }

That can be rewritten as:

if (@ARGV) { if (@ARGV == 1) { Download($ARGV[0]); EXIT(0, 'SUCCESS. Argument was received from command line.'); } PrintUsage(); EXIT(-1, 'Argument missing.'); } Download(GetArgs()); EXIT(0, 'SUCCESS. Argument was received from stdin.');

which reduces the number of lines of code and makes the logic clearer. Even better would be:

use strict; use warnings; if (!@ARGV) { Download(GetArgs()); EXIT(0, 'SUCCESS. Argument was received from stdin.'); } if (@ARGV == 1) { Download($ARGV[0]); EXIT(0, 'SUCCESS. Argument was received from command line.'); } PrintUsage(); EXIT(-1, 'Argument missing.');

which avoids nested code paths altogether. Wherever the code path can't continue out of a previous block there is no need for an else. That avoids nesting following code and generally makes the logic easier to follow.

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

In reply to Re: else after a return, exit, croak, die by GrandFather
in thread else after a return, exit, croak, die by Anonymous Monk

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.