Perl help with Modules
-
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
-
Answer:
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 at Google Answers Visit the source
Related Q & A:
- Do I need to place the contributed modules inside "sites/all/modules" folder for drupal version upgradation from 6 to 7?Best solution by Drupal Answers
- How to build child modules independently from parent in Maven?Best solution by stackoverflow.com
- How to use opencv extra modules?Best solution by answers.opencv.org
- How can I convert a string number to a number in Perl?Best solution by Stack Overflow
- How do I get rid of modules on my yahoo home page?
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.