http://www.perlmonks.org?node_id=1050204
mds has asked for the wisdom of the Perl Monks concerning the following question:

Is it possible to capture the output of stderr in Net::OpenSSH to a variable instead of to a file? In this particular case I want the stderr of the following "new" function not the stderr of commands once I have the connection established.

my $ssh = Net::OpenSSH->new($host); $ssh->error and die "Couldn't establish SSH connection: ". $ssh->error;

ssh->error does not provide all the information I need during a connection failure.
I get different reasons for failure to connect. Some are "administratively denied" other are just "disconnect" and all these messages go to stderr. It looks like I can capture the stderr to a file but I would like to avoid that if possible.