I have a new script that I need to write in perl, to leverage our perl codebase (no, I can’t convert it, not yet anyway). Our coding standards dictate Getopt::Long::GetOptions() but I realize my option handling would be greatly improved and simplified if I could just drop python’s optparse.OptionParser into it. The things I like in python: validation of inputs, both formats and required/optional, and auto help string generation based on argument config.
Any tips? I know I could roll my own, but I’d rather use someone else’s work if it’s already been done.
The canonical tool is Getopt::Long. It’s not "declarative" as such. Is there some specific behavior you are trying to replicate?
EDIT: For more power, you might be interested in App::Cmd or parts of it (see also App::Cmd::Tutorial).
Internally this uses Getopt::Long::Descriptive which seems to meet most of your requirements. This might be especially useful for you because internally it uses
Getopt::Longand Params::Validate, so it might be very easy to move your current code base but now have validation.