Subject: | Enhancement request for version 0.10 |
Date: | Tue, 21 May 2013 12:04:42 -0500 |
To: | bug-Getopt-Modular [...] rt.cpan.org |
From: | Jeff Holt <jeff.holt [...] method-r.com> |
Hi Darin.
Can you please add a getOpts method to Modular.pm so that a user migrating
from Getopt::Long to Getopt::Modular has to modify only a couple of lines?
Presently, such a user would have to modify every line that makes an option
reference.
Here's the code:
sub getOpts
{
my $self = _self_or_global(\@_);
my %opts;
for (keys %{$self->{accept_opts}}) {
$opts{$_} = $self->getOpt($_);
}
return %opts;
}
You could also do the perly thing and modify getOpt method to return
$self->getOpts() when it's not given an argument. I tried testing it and
noticed that there's no test for when getOpt is not given a value. I was
expecting (but didn't get) at least one test to fail when I modified line 2
of getOpt to this:
my $opt = shift;
return $self->getOpts() unless defined $opt;
So, I guess that since there's no such test, then it's safe to make that
change too. And if you were to make such a change, then there'd be no need
to publish getOpts.