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