in reply to Calling another script from Perl/Tk

You should switch from backticks to a pipe open:
open SCRIPT, "<code-to-execute> |" or die "script failed: $!";
As long as your script output is line-based, you can use
<SCRIPT>
to read lines as they are printed (as long as you set $| to 1 inside the script you are calling).

Replies are listed 'Best First'.
Re^2: Calling another script from Perl/Tk
by ravishi (Acolyte) on Oct 22, 2008 at 20:27 UTC
    Thanks for the help! However, could you guide me a little bit farther. I have tried to change my code to this:
    open SCRIPT, "otherScript.pl |" or die "script failed: $!"; $resultsBox->insert('end', $SCRIPT);
    I am sure that I am not implementing this correctly. I am assuming that I will need to do a loop of some sort to keep inserting the new lines until the script is finished. But, I am at a loss with the new code you gave me. Also, I don't know what you mean by I could use <SCRIPT>. My separate code is line-based and should only pass text. I did put a line in my called script of $| = 1;.
      You must be really new to perl. SCRIPT in this case is a filehandle, not a scalar or array. You should be able to do something like
      open SCRIPT, "otherScript.pl |" or die "script failed: $!"; while (<SCRIPT>) { $resultsBox->insert('end', $_); } close SCRIPT;