|
|
Subject:
Perl help with Modules
Category: Computers > Programming Asked by: mickr-ga List Price: $20.00 |
Posted:
23 Jul 2004 05:06 PDT
Expires: 22 Aug 2004 05:06 PDT Question ID: 378055 |
Hi, I am after some help with using PERL modules. I am trying to read options using the Getopt:Long module as follows; #!/usr/bin/perl # import module use Getopt::Long; # set default value for option $debug = 0; # get value of debug flag $result = GetOptions ("debug" => $debug); # print value print "Debug flag is $debug"; However when I call this programme ./script.pl gives Debug flag is 0 ./script.pl --debug gives Debug flag is 0 The module seems to exist. If I try use Getopt::Long1; instead I get a message that Getopt/Long1.pm doesn't exist and gives me the search path as well. I can see Getopt/Long.pm module is in the search path and it has the GetOptions subprogramme. If I do perl ./script.pl -w --debug I get Name "main::result" used only once:possible typo at script.pl line 7. Where $result = GetOptions ... is line 7. What am I doing wrong? Thanks, Mick |
|
Subject:
Re: Perl help with Modules
Answered By: palitoy-ga on 23 Jul 2004 06:08 PDT Rated: |
Hi Mick This had me stumped for a little while too until I noticed you had made a minor typo by missing off a \. The line: $result = GetOptions ("debug" => $debug); should read: $result = GetOptions ("debug" => \$debug); Let me know if this solves your problem. A couple of useful pages on this module are here: http://perl.active-venture.com/lib/Getopt/Long.html http://www.devshed.com/c/a/Perl/Processing-Command-Line-Options-with-PERL/0/ Note - on this second article the \'s are also all missing (I guess this is due to the way the HTML is presented). | |
| |
| |
| |
|
mickr-ga
rated this answer:
and gave an additional tip of:
$30.00
Thanks, I am a happy customer as usuall. |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |