1
votes

I'm trying to call perl1.pl which is in another folder with switches from another perl script say perl2.pl. Usually perl1 is called like:

perl1.pl -arg $arg1 -arg2 $arg2

Now the problem is $arg1 gets generated internally from program perl2 and $arg2 is obtained from the switch when perl2 is executed like this.

perl2 -arg2 $arg2.

I tried using system command to call perl1.pl but it isn't working. Is there any way to do this? There are also few arguments in perl1 which accepts from the user which are always required. I'm not sure how to send them.

2
"isn't working" isn't helping finding a solution.René Nyffenegger

2 Answers

1
votes

Some example would be usefull. You could use backticks to capture the output of an executable.

### in perl1
my $ret = `$perl2 -arg2 $arg2`;
chomp($ret);
print "ret: $ret\n";
0
votes

You can use CPAN module IPC::System::Simpleto capture the output. For more details have a look here : IPC::System::Simple

my $output = capture("some_command", @args);