I do this all the time with the exec function.
$cmd = "perl myscript.pl 1>&2"; // that 1>&2 at the end routes stdErr to stdOut
$output =NULL;
$retvar = NULL;
exec($cmd, $output, $retvar);
if ($retvar) {
echo "You probably had an error";
}
var_dump($output);