Microsoft
Software
Hardware
Network
Question : Perl GetOptions: Undefined argument in option spec
Hi guys, hope u r all well.
Guys im trying to learn how to read command line arguments by using the GetOpt module, but each time i run the following examples, which im assuming "should" work im getting an error saying:
"Undefined argument in option spec"
Here are the examples:
==========================
==========
==========
==========
========= example1.pl
#!/usr/bin/perl
# import module
use Getopt::Long;
# read options
$result = GetOptions ("age=i" => $age);
# print value
if ($age) { print "Input age is $age years"; }
==========================
==========
==========
==========
========= example2.pl
#!/usr/bin/perl
# import module
use Getopt::Long;
# read options
$result = GetOptions ("name=s" => $name);
# print value
print "Input name is $name";
When I run these examples with or without options specified, im getting the following...
Undefined argument in option spec
Id love to know what is happening.
Thank you :>)
Answer : Perl GetOptions: Undefined argument in option spec
From what I see here:
http://search.cpan.org/~jv
/Getopt-Lo
ng-2.37/li
b/Getopt/
L
ong.pm
you need a leading slash infront of the $:
$result = GetOptions ("age=i" => \$age);
$result = GetOptions ("name=s" => \$name);
Random Solutions
Date/Time Stamp an Excel Workbook
Delegate ability to add computers to domain but not delete
Sort by only last digit in a column in excel
bad_pool_caller error when loading os
how to open a port on cisco 1700
How to migrate Domain Controller (Windows 2003 Server SP1) running on Compaq Proliant 1600 server to different hardware of desktop computer (in a lab)
Unix update variable by position
Exchange 5.5 - How to setup a smarthost to provide Pop3 access, without mailboxes
Create unattended installation of Office 2003 Sp2,Winxp sp2,Win 2003 sp1 and sp2
Need help migrating to Access 2007 from 2003