in reply to Wrapper headache - Getopt::Long screw up w/ '--' and missing opt value

I really don't use Getopt::Long very often, but the docs seemed pretty clear to me...

= type [ desttype ] The option requires an argument of the given type. Supported types are: s String. An arbitrary sequence of characters. It is valid for the argument to start with "-" or "--".

If you want your debug option to take an optional argument, you can specify that with a colon instead of an equals; i.e. 'debug:s' rather than 'debug=s'.

How do people cope when writing a a Perl wrapper which accepts known & unkwon options for the wrapped program?

Have you looked at how to use Getopt::Long::Configure() to configure Getopt::Long's behavior? It seems that you can use Getopt::Long::Configure('pass_through') to tell Getopt::Long to leave unknown options in @ARGV. You might want to use it with Getopt::Long::Configure('require_order') or Getopt::Long::Configure('permute') as well.

-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re: Re: Wrapper headache - Getopt::Long screw up w/ '--' and missing opt value
by parv (Parson) on Feb 10, 2003 at 04:25 UTC

    Do'h! I missed the part that says that a string can start w/ '--'. Mea culpa.

    I am aware of use of [:=] to make the option take a an optional argument or not. As presented in the code, i used '=' to require a value for the specified option.

    I also noted, though very indirectly, in OP that "pass_through" makes the process interesting when i wrote "other options are passed as is". My frustation resulted after trying various configuration options.

    All in all, thanks for the clue. I will try other things.