in reply to Command Line Options without "-" or "- -"
Or you could use G::D, but this might be overkill:$option_line = join ' ', @ARGV; #reconstitute my @pairs = $option_line =~ m/(\w+:\s+\w+)/g; # grab option pairs my %option; for $pair (@pairs) { # now split my ($name,$value) = split ":\s+", $pair, 2; # save each pair in hash $option{$name} = $value; }
(I can't recall if whitespace is automagically optional, and I have to run %/;)our %opt_hash; #can't use my use Getopt::Declare; my $spec = q{ <name>: <value> Name/Value pair { $::opt_hash{$name} = $value; } [repeatable] }; # untested
Update: Missing $option_line corrected.
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Command Line Options without "-" or "- -"
by parv (Parson) on May 16, 2006 at 18:25 UTC |