in reply to Re^2: generic getopt to hash
in thread generic getopt to hash

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!