jsks
jsks

Reputation: 61

perl Getopt::Long output issue

Testing the Getopt::Long perl and when executed with arguments to options print command output is 1 instead supplied argument.

Here is the code..Could not locate what is missing here.

#!c:\Perl\bin
use Getopt::Long;

(@ARGV) or die "$0 --file <file name> --cb <CBEntry>";

GetOptions( "file" => \$file,
            "cb" => \$cb) or die "$0 --file <file name> --cb <CBEntry> :$! \n";

#print @ARGV;
print $file;
print $cb;

Upvotes: 0

Views: 92

Answers (1)

ikegami
ikegami

Reputation: 385657

The following indicates a argument-less option:

"file" => \$file

To accept a string argument, use the following:

"file=s" => \$file

Option Specifications

Upvotes: 3

Related Questions