A bug or perl sucks

S

Steven Zhang

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. You have to do some
thing like this:
perl c:\testl.pl -d "c:\program files\\" -f "some file"
 
J

Jürgen Exner

Steven said:
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
 
S

Steven Zhang

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 );

}
 
E

Eric

This sounds more like a shell type issue, even in Windows the command
line has to make sense of what you are typing before Perl gets it.

For example I often find it a major pain that I have to do this:

find ./ -name \*.pm

Just the *.pm won't work.

# find ./ -name *.pm
find: Application.pm: unknown option

This is because of globbing, but I wonder if the / problem you are
having is something along the same lines.

Thanks,

Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top