You don't need to enumerate abbreviations. Getopt::Long allows the user to specify options using the smallest unique abbreviation. For example... if you have an option called 'help', the user can specify '--h' on the commandline and it will automatically work. If you have an option 'help' and 'hop', the smallest unique abbreviations would be '--he' and '--ho'.

This also works for '--no*' options. For example, if you have a switch called 'try', and you set up the capability for it to be negated with 'notry', you can also use the abbreviations '--t' and '--not'.

Again, this is all automatic by default in Getopt::Long. It can be disabled, tweaked, etc., but by default, you get this behavior. So the ramification is that it's unnecessary to specify 'help|h' as an option, because if your option is specified as 'help', the user can enter 'help', 'hel', 'he', and 'h', as long as each of those abberviations is unique.


Dave


In reply to Re: Need help using Getopt, please. by davido
in thread Need help using Getopt, please. by Seventh

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.