my $out = ''; my $err = ''; foreach my $one(@cmds) { my ($stdout,$stderr,$exit) = $ssh->cmd($one) ; $out .= $stdout; $err .= $stderr; warn "'$one' has exit value $exit\n" if $exit; } print $out; # all the outputs concatenated print $err; # all the errors concatenated