in reply to Re^2: Modules which improve system() ?
in thread Modules which improve system() ?

As I just mentioned in this post, how about IPC::Run3?

From its Pod:

compared to system(), qx'', open "...|", open "|...": + redirects more than one file descriptor + returns TRUE on success, FALSE on failure + throws an error if problems occur in the parent process (or the +pre-exec child) + allows a very perlish interface to Perl data structures and subr +outines + allows 1 word invocations to avoid the shell easily: run3 ["foo"]; # does not invoke shell - does not return the exit code, leaves it in $?

So you could use it like this:

eval { run3 $program } or die "Errors running $program";

Its docs leave a bit to be desired, but the current maintainer might be willing to take some doc patches...

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Replies are listed 'Best First'.
Re^4: Modules which improve system() ?
by adamk (Chaplain) on Jun 24, 2006 at 23:44 UTC
    I concur with my learned friend on IPC::Run3 as a direct replacement to system(), although it can't do some of the more interactive tricks of IPC::Run.

    Morover, IPC::Run3 works on every single platform flawlessly, and so it makes for a very safe dependency. Some of the others do have the odd platform issue.