In Perl's Getopt::Long version 2.39 I could use
use Getopt::Long qw( :config gnu_getopt );
GetOptions(
\my %opts,
"codon-view|c:20", # Optional value, default 20
"consensus|C:50",
...
)
to indicate that if I use -c
the default value would be 20 put in %opts
under key codon-view
when -c
is given but no explicit value for it is there. On the other hand -c
or --codon-view
is not supplied, then no value in the hash table is stored for in %opts
.
In 2.48 this no longer works and I don't see in Getopt::Long's documentation
$ perl -E'
use Getopt::Long qw( :config gnu_getopt );
say $Getopt::Long::VERSION;
GetOptions(\my %opts, "codon-view|c:20");
say $opts{"codon-view"} // "[undef]"
' -- -c
2.39
20
$ perl -E'
use Getopt::Long qw( :config gnu_getopt );
say $Getopt::Long::VERSION;
GetOptions(\my %opts, "codon-view|c:20");
say $opts{"codon-view"} // "[undef]"
' -- -c
2.48
[undef]
How can I achieve the old behavior?
Help!
tag=s
ortag:i
, nottag:20
. – Month-c
or--codon-view
is given without a value that the behavior changes betwee 2.39 and 2.48. Also there are changes in FindOption that change between those two versions with respect tognu_getopt
. – Ergotism: number
– Loftin