run a program and capture stdout and completion status?

hansel on 2006-02-12T22:20:22

I'm looking for a snippet or simple module that run an external command and capture the completion status and stdout. I found some partial snippets in the camel book, but I'd really prefer something a bit more tested/complete. This is my note to dive into CPAN. Any suggestions are appreciated.

-james.


Backticks

bart on 2006-02-13T00:14:14

According to perlop, you can simply use backticks AKA qx to run the external command and capture STDOUT; the status will be returned in $?.
A string enclosed by backticks (grave accents) first undergoes double-quote interpolation. It is then interpreted as an external command, and the output of that command is the value of the backtick string, like in a shell. In scalar context, a single string consisting of all output is returned. In list context, a list of values is returned, one per line of output. (You can set $/ to use a different line terminator.) The command is executed each time the pseudo-literal is evaluated. The status value of the command is returned in $? (see perlvar for the interpretation of $? ).

Re:Backticks

Ron Savage on 2006-02-13T05:36:14

IPC::Run3

Re:Backticks

Alias on 2006-02-13T12:34:02

What he said

IO::Capture

domm on 2006-02-13T06:55:46

IO-Capture