in reply to Re: -x accepts up to 3 additional arguments
in thread -x accepts up to 3 additional arguments
I think this is the closest to a "best solution" compared to some the others listed. Define a callback handler for your options such as:
my $flag, @args; my %more = ( x => 2, y => 1, z => 0 ); GetOptions( 'x=s' => \&parse_opt, 'y=s' => \&parse_opt, 'z=s' => \&parse_opt, ); sub parse_opt { my ($opt, $val) = @_; # splice additional args off @ARGV based on how many I expect push @args, $val, splice @ARGV, 0, $more{$opt}, (); }
Of course, all of this is going to depend on what you want to do with things later and on whether then number of params that -x and -y take varies, etc.
|
|---|