I've never used Getopt::Easy so I won't comment on that. But here's the idiom I use for Getopt::Long. I'm so used to it I don't have to think--easy enough for me!

GetOptions \our %Cmdline, qw(input|i=s output|o=s foo=i bar:i baz);

To tell the truth "=s" is the only spec I really use nine times out of ten :)

The nice thing about this is that I get a global with convenient longnames that are the same as the longnames on the command line: $Cmdline{input} etc.

Sure, there's a lot missing here. This doesn't wire into the POD of my script, and it doesn't generate --usage notes. And those are tedious to write and there are "better" modules out there. They aren't core, though, and some have other disadvantages, so for casual programming with Perl 5, I stick to Getopt::Long.

Recently in a larger project I've used App::CLI (although App::Cmd seems similar yet more featureful, I had deployment issues with it). YMMV.

ObPerl6: in Perl 6, this is so much better :) The entry point to your program is always a subroutine called MAIN, and get this, the signature (Perl 6 has function signatures) captures the command line arguments for you (Perl 6 has function signatures powerful enough to express almost anything you'd care to spec on the command line). Nifty!


In reply to Re: Seeking Getopt recommendations - anyone used Getopt::Easy? by gaal
in thread Seeking Getopt recommendations - anyone used Getopt::Easy? by theguvnor

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.