in reply to Help required on Getopt::Long

Problem Solved!

Just replace '=' with ':' at line 5

Here is the code.

use Getopt::Long; my $abc; my $help; GetOptions ( "abc:s" => \$abc, "help" => \$help ); if ($help) { print "This is help message\n" ; exit ;} if ($abc) { print "You have choosen \"abc\" as $abc" };

You can get more information on Getopt::Long here

Replies are listed 'Best First'.
Re^2: Help required on Getopt::Long
by Anonymous Monk on May 16, 2012 at 11:58 UTC

    Replacing equal sign with colon alone does not solve the problem. It changes the problem by making the value for option abc optional instead of being required; equals sign impose that a value need to be specified ...

    = type [ desttype ] [ repeat ] The option requires an argument of the given type. . . . : type [ desttype ] Like "=", but designates the argument as optional. If omitted, an empty string will be assigned to string values options, and the value zero to numeric options.

      ".. equals sign impose that a value need to be specified ..." -- self.

      GAAH! Make that "... equals sign imposes that a value is need to be specified ...".