A bug or perl sucks

Discussion in 'Perl' started by Steven Zhang, Sep 20, 2004.

  1. Steven Zhang

    Steven Zhang Guest

    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"
    Steven Zhang, Sep 20, 2004
    #1
    1. Advertising

  2. 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
    Jürgen Exner, Sep 20, 2004
    #2
    1. Advertising

  3. Steven Zhang

    Steven Zhang Guest

    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
    >
    >
    Steven Zhang, Sep 20, 2004
    #3
  4. Steven Zhang

    Eric Guest

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

    >
    >
    >
    Eric, Sep 21, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    96
    Views:
    2,259
    Monique Y. Mudama
    Feb 7, 2006
  2. Nomen Nescio
    Replies:
    10
    Views:
    760
    brucie
    May 26, 2004
  3. Anonymous via the Cypherpunks Tonga Remailer

    GODADDY SUCKS--DO NOT REGISTER DOMAIN NAMES WITH THEM

    Anonymous via the Cypherpunks Tonga Remailer, May 26, 2004, in forum: HTML
    Replies:
    0
    Views:
    376
    Anonymous via the Cypherpunks Tonga Remailer
    May 26, 2004
  4. Anonymous
    Replies:
    0
    Views:
    406
    Anonymous
    May 26, 2004
  5. Java sucks, Perl Rules.

    , Jan 27, 2006, in forum: Perl Misc
    Replies:
    98
    Views:
    674
Loading...

Share This Page