use IPC::Run3 qw( run3 ); my $cmd = "cmd /D/C dir"; run3 $cmd, undef, \my @out, \my @err; print "STDOUT: $_" for @out; print "STDERR: $_" for @err;