Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: GetOptions option with value and no space

by RichardK (Parson)
on Jul 12, 2015 at 12:07 UTC ( [id://1134365]=note: print w/replies, xml ) Need Help??


in reply to GetOptions option with value and no space

I don't think that is a bug, That's just how bundling works. see the bundling section in the docs Getopt::Long

If you add

Getopt::Long::Configure ("bundling_values");

It does what you want.

Replies are listed 'Best First'.
Re^2: GetOptions option with value and no space
by u65 (Chaplain) on Jul 12, 2015 at 12:21 UTC

    I see that bundling is disabled as the default, thus the OP problem script should work as I see it.

    update: Hm, when I use your configure 'bundling_values' the options should be case sensitive, but the original code has 'S=i' and when I execute:

    $ ./tst.pl -S4

    I get

    Unknown option: S4 0
      There does seem to be a problem with how the module handles case when "bundling_values" is turned on...

      When GetOptions is given 's=i' (lowercase) all works as expected:

      Getopt::Long::Configure ("bundling_values"); my $myOpt = 0; GetOptions('s=i'=> \$myOpt); print "bundling_values\n"; print "$myOpt\n\n"; $ test.pl -S1 Unknown option: S1 bundling_values 0 $ test.pl -s1 bundling_values 1
      When GetOptions is given 'S=i' (uppercase) works opposite to expected:
      Getopt::Long::Configure ("bundling_values"); my $myOpt = 0; GetOptions('S=i'=> \$myOpt); print "bundling_values\n"; print"$myOpt\n\n"; $ test.pl -S1 Unknown option: S1 bundling_values 0 $ test.pl -s1 bundling_values 1
      Workaround by adding 'ignorecase_always' option:
      Getopt::Long::Configure ("bundling_values", "ignorecase_always"); my $myOpt = 0; GetOptions('S=i'=> \$myOpt); print "bundling_values, ignorecase_always\n"; print "$myOpt\n\n"; $ test.pl -S1 bundling_values, ignorecase_always 1 $ test.pl -s1 bundling_values, ignorecase_always 1

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1134365]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-19 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found