How to call shell script into perl?

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

Was this solution helpful to you?

Find solution

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.