in reply to Re: output from an external program
in thread output from an external program

Thank you - that was exactly what I was looking for.

Replies are listed 'Best First'.
Re^3: output from an external program
by merlyn (Sage) on Dec 01, 2005 at 14:44 UTC
    If you don't need interaction, consider a two-stage fork, which is safer than having one program both send and recieve with IPC::Open3, since you can never deadlock by being the wrong state. For example:
    if (open RESULTS, "-|") { # I am the original process, so read from <RESULTS> below } else { # I am the kid if (open STDIN, "|-") { # I am still the kid, but my STDIN is now piped from the grandkid exec "your", "big", "application"; die "can't find big application: $!"; } else { # I am the grandkid: be a data pump print "$_\n" for @input_data; exit 0; } } while (<RESULTS>) { .... }
    This double-fork data-pump is a nice pattern to keep in mind.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.