use Capture::Tiny 'capture'; ... my ($stdout, $stderr, $exit) = capture { system($cmd, @args); };