Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > A bug or perl sucks

Reply
Thread Tools

A bug or perl sucks

 
 
Steven Zhang
Guest
Posts: n/a
 
      09-20-2004
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"


 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      09-20-2004
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


 
Reply With Quote
 
 
 
 
Steven Zhang
Guest
Posts: n/a
 
      09-20-2004
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" <> 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
>
>



 
Reply With Quote
 
Eric
Guest
Posts: n/a
 
      09-21-2004
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" <> 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
>>
>>

>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
*bug* *bug* *bug* David Raleigh Arnold Firefox 12 04-02-2007 03:13 AM
Java sucks, Perl Rules. atbusbook@aol.com Java 96 02-07-2006 12:59 AM
Java sucks, Perl Rules. atbusbook@aol.com Perl Misc 98 02-07-2006 12:02 AM
perl bug File::Basename and Perl's nature Xah Lee Python 14 01-27-2004 08:20 AM
perl bug File::Basename and Perl's nature Xah Lee Ruby 13 01-27-2004 07:23 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57