Home Ask Login Register

Developers Planet

Your answer is one click away!

jsks February 2016

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;

Answers


ikegami February 2016

The following indicates a argument-less option:

"file" => \$file

To accept a string argument, use the following:

"file=s" => \$file

Option Specifications

Post Status

Asked in February 2016
Viewed 3,512 times
Voted 10
Answered 1 times

Search




Leave an answer


Quote of the day: live life