-1

I have been trying to make GetOpts :: Long work for my code but it just doesn't respond. I have a wrapper script with about 8 scripts and 2 commands. I have been trying to GetOpts :: Long submit arguments into the separate codes, but it doesnt work!

For example, I've script 1 though 8, and on the command line I'm trying to a few options that I would like to submit to the separate scripts. When I use the GetOpts module in the seprate scripts and run them separately, they run fine. But when I try to run the wrapper script, say wrapper.pl which initiates script 1 with the module being called in it; the arguments submitted are not being taken by the separate scripts.

Please help!!!!

I hope this sort of explains the problem. wrapper script looks like this(wrapper.pl),using backticks:

perl script1.pl;

perl script2.pl; (etc)

script1.pl uses the GetOpts::Long option for the input file. script1.pl calls for the input file using the "-i" option, but the file is not being read when initiated on the command line.

command line option: perl wrapper.pl -i seqs.fa -o op.fa

J_Dow
  • 1
  • 1
  • 3
    You should at least show us the wrapper. – simbabque Dec 05 '16 at 08:56
  • Since there is no code to look at, it's a mere guessing from what you described. –– Do you actually pass in the arguments from your wrapper.pl into the scripts ? - how would they magically know what options they need to handle? Oh... and before you think you can simply pass in `@ARGV` at that time, you will be wrong, `@ARGV` will be consumed after parsing the options. (except for those after the double dash) – vanHoesel Dec 05 '16 at 09:25
  • Please provide a minimal, runnable demonstration of the problem. – ikegami Dec 05 '16 at 18:39

1 Answers1

0

Do you actually pass in the arguments from your wrapper.pl into the scripts ? - how would they magically know what options they need to handle?

vanHoesel asked the right questions; you have to do something like that in wrapper.pl:

use Getopt::Long;
GetOptions('i=s' => \$input_file,
           'o=s' => \$output_file) || die "Usage: $0 -i INPUT -o OUTPUT\n";
`perl script1.pl -i $input_file`;
`perl script2.pl -o $output_file`;
Armali
  • 18,255
  • 14
  • 57
  • 171