The problem is: it is not consistent. The first "\" does not interpolate.
However, the last "\" gets interpolated, which escapses the close double
quote.
E.g, if it is -d "c:\\program files\\", the parsed value of option d will
be: c:\\program file\. If the options are -d "c:\program files\" -f ..., the
value of option d is: c:\program files" -f ... and no value of option f.
Here is the code:
use Getopt::Long ;
our $Usage = "Usage: test.pl -d=<full path> -f=<a filename\n";
our %options = ();
unless ( GetOptions ( \%options,
'd=s',
'f=s',
'help',
) ) {
print ( $Usage ) && exit( 1 );
}
print "option d: ".$options{"d"}."\n" if $options{"d"};
print "option f: ".$options{"f"}."\n" if $options{"f"};
unless ( $options{"f"}) {
print ( $Usage ) && exit( 1 );
}
"Jürgen Exner" <ju******@hotmail.com> wrote in message
news:E5H3d.6227$vd1.4809@trnddc03...
Steven Zhang wrote: Run a program like this:
perl c:\temp\test.pl -d "c:\program files\" -f "some file".
Getopt::Long
Getoptions is unable to correctly parse the options.
This statement is close to useless.
What do you expect the result of Getoptions to be, what do you actually
observe, and in how far do those two differ?
You have to do
some thing like this:
perl c:\testl.pl -d "c:\program files\\" -f "some file"
Do something like this to achive _what_?
Please post a minimal, but complete program that demonstrates your
problem. I'm sure someone will be able to help you.
jue