Thanx for the pointer.

Acc. to docs, = type [ desttype ] [ repeat ] allows things like GetOptions ('list=s{1,}')(?) to allow a variable length list. Should work nicely for postive integer lists (i). But it seems to have the slight problem that for strings (s), all remaining args from @ARGV are eaten DOC CONTRADICT IMPL **, even if you'd like to stop the list before say the next string starting with a minus WORKS (or an argument that is existing in the filesystem, which you may or may not treat as the first non-option argument instead AFAICS UNSUPPORTED).

An argument on why such vararg-options might be sometimes convenient: quoting s/hell: The normal way for multi word lists as arguments to an option is probably using a single string and splitting it on whitepace. But if the words themselves are allowed to contain both quoting and whitespace, it might be worthwile to skip having both shell and perl doing quote interpolation and thus shave off an extra layer or two of the quoting has to use on entering the command in the shell.

Is there a getopts variant that allows still a bit more for such a scenario?

Updated: ** is from my reading of the docs for 2.38, while Elisheva's code shows that the current module does stop "eating" at the start of a new option. Kudos to Elishiva for her comment below!

In reply to Re^3: generic getopt to hash by jakobi
in thread generic getopt to hash 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.