use IO::CaptureOutput qw( qxx ); my ($stdout, $stderr) = qxx( $somecommand, @args, $filename );