perldoc: http://perldoc.perl.org/Getopt/Long.html. GetOptionsFromArray([glob($input_line)],...)
Альтернатива:
sub foo {
local @ARGV = @_;
my $res = GetOptions(...);
}
use Getopt::Long;
sub do_awesome_things
{
local @ARGV = @_;
GetOptions(
'files=s' => \my @files,
'verbose!' => \my $verbose,
);
warn "Going to process files @files. "
. "Verbose is ".( $verbose ? 'ON' : 'OFF' ).".\n";
}
do_awesome_things -v => -file => 'foo.txt', -file => 'bar.txt';
Default values:
my $verbose = ''; # option variable with default value (false)
my $all = ''; # option variable with default value (false)
GetOptions ('verbose' => \$verbose, 'all' => \$all);