(Perl) Capture STDOUT and STDERR from Perl, XS or external programs