http://qs1969.pair.com?node_id=1049640


in reply to easiest way to read multiple word command arguments

Here's another variation on the same theme. In this case a new array is created from @ARGV with multiple words collapsed into one array element. The advantage is that this rebuilt version of @ARGV can be fed into Getopt::Long's GetOptionsFromArray method:
use strict; use warnings; use Getopt::Long qw(GetOptionsFromArray); my @arglist = (); for my $arg (@ARGV) { if ($arg =~ /^-/) { push(@arglist, $arg); } else { if ($arglist[$#arglist] =~ /^-/) { push(@arglist, $arg); } else { $arglist[$#arglist] .= ' '.$arg; } } } my ($opta, $optb, $optc); GetOptionsFromArray(\@arglist, 'a=s' => \$opta, 'b=s' => \$optb, 'c=s' => \$optc); for ($opta, $optb, $optc) { print $_,"\n"; }