Question:

How to run a perl script in another perl script??

by Guest61608  |  earlier

0 LIKES UnLike

I have one perl script one.pl which calls another perl script two.pl.The output two.out is input for one.pl.I am using system command for this.But when I package it to make exe and try to run it in machine where perl is not installed it is not working..I tried with do and require also..But they are also not working..please help me...

 Tags:

   Report

1 ANSWERS


  1. Sounds like you have two problems.

    1) You need the output from "two.pl".  I'm not clear whether you mean you need the actual output from STDOUT or from an output file "two.out".  If it's from a file, then never mind, but if you need the STDOUT of "two.pl", then running in a system call won't give you what you want.  The system command in Perl won't give you the output, it will just give you the exit value of the command you ran.  Instead, you want backticks:

    $return_code = system('perl two.pl'); #output gone!

    - OR -

    $std_output = `perl two.pl`;

    $return_code = $?;

    2) Your second problem is that you don't have Perl installed on your target machine.  That's a problem.  If you're packaging them into .exe files in order to avoid installing Perl (using PerlCC or something?), you'll have to do this twice.  In other words, build one for "two.pl", and call that .exe file from "one.pl", rather than call the actual Perl script.  Of course, the easier option may be to simply combine the two scripts into "one.pl" rather than have two distinct scripts.  But that would likely require some tweaking, depending on what you're doing.

    DaveE

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.