pericmd 004: What’s wrong with Getopt::Long (2)

In the previous post I mentioned about some things I would like to change in Getopt::Long, but this is rather opinionated and I’m not sure they should be implemented. Here goes:

Some old crufts. Since this is a very old library, there are some features that are very seldom needed these days that they make good candidates for removal, to make the library smaller and easier to use. The first one is the ignore_case configuration. I always use no_ignore_case nowadays and it’s common for programs to have options that differ only in case, like -v (for version) vs -V (for verbose). I think it’d just be less confusing if Getopt::Long is always case sensitive.

Another one is the getopt_compat configuration. Any program in circulation you saw lately which uses + prefix for options, instead of --? The world has mostly standardized on the dashes.

Trapping errors in option handler. Getopt::Long encloses an eval { } when executing option handler. I think there should be an option to disable this, so an option handler can make the whole option parsing process exit early. Currently this is not possible, due to the error trapping.

Well, that’s about it. Much shorter than I expected 🙂

Leave a comment