A pipe can be attached to the output stream:
$pssh->push('*', 'command', { stderr_to_stdout => 1,
stdout_file => ['|-', 'perl', '-ne', 'pr
+int "%HOST%$_\n"'] },
$cmd );
Or the more efficient:
require POSIX;
my %fh;
for my $host (@hosts) {
my $pid = open my $fh, '|-';
if (not $pid) {
while (<>) {
print "$host) $_";
}
POSIX::_exit(0);
}
$fh{$host} = $fh;
$pssh->add_host($host, default_stderr_fh => $fh, default_stdout_fh =
+> $fh);
}
$pssh->push('*', 'command', $cmd );
$pssh->run;
close $_ for values %fh;
Note that lines comming from stderr and stdout may arrive intermixed. A more correct solution would be to use different filters for stderr and stdout.