on-internet
← Community

Getopt::Long, Optional Arguments, and Greediness

Stack Overflow ·

I'm trying to write a program that has an option that takes an optional argument, in such a way that it accepts options in the same fashion with the exact same behavior as perl -i or git --color. Unfortunately Getopt::Long doesn't exactly work that way and I can't get it to. Allow me to explain. Example #1: If you run perl -i .bak, it does not use .bak as a backup file extension for editing in-place, as perl -i.bak would. Example #2: If you run git diff --color always, it does not specify always for the --color option; for that you must use --color=always. I call that "non-greedy". I cannot fi

Comments

Sign in or sign up to comment and upvote.

No comments yet.