bonoboy has asked for the wisdom of the Perl Monks concerning the following question:

Hi there,

I'm trying to use both getopt::std and long in my code. Std is handy for easy stuff like '-u username' and shwhatnot, but there's some longer predefined functions which are better with longer names.

The problem is, they don't seem to play well together. Each of them returns 'option unknown' for the other one, depending on what order they're in in the code.

Anyone know a workaround for this?

Update: Yup, cheers Hena. Also the 'no_autoabbrev' function is useful, as otherwise it'll catch std-form options and evaluate them as shorthand for the long-form ones as well.

toeslikefingers.com - because you've got too much time on your hands

Replies are listed 'Best First'.
Re: interworking getopt::long and std
by Hena (Friar) on Mar 16, 2004 at 10:04 UTC
    I've used only Getopt::Long. But it can use 'pass_through' option to let the unknowns without complaining. Read perldoc Getopt::Long for more explations on it.

    Although since Getopt::Long is not that hard to use, I do suggest that you use for all situations. Since it allows easy way to bundle options and make your program work like pretty much any other "normal" commanline program (eg 'gnu_getopt' is good option).
Re: interworking getopt::long and std
by Aristotle (Chancellor) on Mar 16, 2004 at 14:28 UTC
    Why not just handle all cases using Getopt::Long? After all it understands short options as well as long ones.

    Makeshifts last the longest.