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