I must say was rather surprised by that remark. It's worth spelling out in full:

What seems to happen is that at first we just want to add--oh say for example JUST ONE, SINGLE LITTLE -v flag. Well, that's so easy enough to hand-hack, that of course we do so; maybe like this:

if (@ARGV && $ARGV[0] eq '-v') { $verbose = 1; shift @ARGV; }

I couldn't believe anyone (still?) reasons this way. In the case of command-line arguments, I find this line of reasoning is unconscionable. Sooner or later, and likely sooner, there will be a second option, and at that point, if you don't refactor you have just doubled your technical debt.

Similarly, Larry's remark about not using a Getopt::* library because it didn't seem worth the bother to load it in for just an opt or two to be a bad case of premature optimisation.

I'm happy to cut them slack because twenty years ago, people didn't know any better :) But in this day and age there is absolutely NO reason for rolling your own command-line processing. Any more than no-one should be decoding CGI paramters manually.

• another intruder with the mooring in the heart of the Perl


In reply to Re: Use Getopt::Long even if you don't think you need to by grinder
in thread Use Getopt::Long even if you don't think you need to by ysth

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.