Subject: | Undefined value for $wantarray in Net::SSH2 connect() method |
In a situation where I want to attempt connection to a remote host which
might be down, I'm getting a failure in the call to connect():
my $ssh = Net::SSH2->new();
$ssh2->poll(1);
if (!$ssh2->connect($host)) {
print "Failed connection ('$host' still down')\n";
return 0;
}
and getting the error:
Use of uninitialized value in numeric eq (==) at
/usr/local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi/Net/SSH2.pm line
226
This is probably because of the comparison of $wantarray to undef in
line 226:
if ($wantarray == undef) {
which seems as easy to fix as:
if (!defined($wantarray)) {