I also don't see a way to do that via configuration options at the moment. But @ARGV is just an array of strings, so you could just do e.g. "s/^-ot\K$/=/ for @ARGV;" before the GetOptions call:
use warnings; use strict; use Getopt::Long qw/ GetOptionsFromArray /; use Test::More tests => 6; my @argv1 = qw/ -ot=123 arg1 arg2 /; s/^-ot\K$/=/ for @argv1; is_deeply \@argv1, ["-ot=123", "arg1", "arg2"]; GetOptionsFromArray(\@argv1, \my %opts1, "ot:s") or die; is_deeply \%opts1, { ot => 123 }; is_deeply \@argv1, ["arg1", "arg2"]; my @argv2 = qw/ -ot arg1 arg2 /; s/^-ot\K$/=/ for @argv2; is_deeply \@argv2, ["-ot=", "arg1", "arg2"]; GetOptionsFromArray(\@argv2, \my %opts2, "ot:s") or die; is_deeply \%opts2, { ot => "" }; is_deeply \@argv2, ["arg1", "arg2"];
Update: Switched from Data::Dump to Test::More.
In reply to Re: Force Getopt::Long to Require ONLY Equals Sign Between Option Name and Value
by haukex
in thread Force Getopt::Long to Require ONLY Equals Sign Between Option Name and Value
by roho
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |