my ($stdout, $stderr, $ret) = capture { system('foo', ($somearg ? ('--somearg' => $somearg ) : ()), ($otherarg ? ('--otherarg' => $otherarg) : ()), ); };