I would like to be able to handle options like -1
or -10
similarly to how head
or -tail
do.
In other words, be able to do
my_script.pl -10 --some-other-option arguments
and be able to retain the value of the -10
option.
Right now the only idea that works is processing the command line before it is fed to describe_options like so:
my ($count) = map { /\-(\d+)/; $1 } grep { /^\-(\d+)$/ } reverse @ARGV;
@ARGV = grep { !/^\-\d+$/ } @ARGV;
my ($opt, $usage) = describe_options(...)
but it looks clunky, and the option doesn't pop up in $usage
.
Is there a better way? Answers using Getopt::Long will work too - I can adapt them to GetOpt::Long::Descriptive