471,830 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,830 software developers and data experts.

A bug or perl sucks

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"
Jul 19 '05 #1
3 3892
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
Jul 19 '05 #2
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

Jul 19 '05 #3
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
Steven Zhang wrote:
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



Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by I Report, You Decide | last post: by
6 posts views Thread by DesignGuy | last post: by
58 posts views Thread by @ | last post: by
9 posts views Thread by Roy Smith | last post: by
23 posts views Thread by John M. Gabriele | last post: by
49 posts views Thread by Relaxin | last post: by
6 posts views Thread by Richard Trahan | last post: by
385 posts views Thread by Xah Lee | last post: by
16 posts views Thread by zwetan | last post: by
NeoPa
reply views Thread by NeoPa | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.