in reply to Net::SSH2 strangeness

$@ is the error returned by an eval. I think you want to display $!, the error returned by almost anything else. (Please note that no error is displayed after the name of the host you're connecting to.)

Make this change, run it again, and you'll have a better idea what the problem is.

(Sorry, I don't know why the connect is complaining about a bad concatenation, although I'm certain someone else will be able to answer that.)

Replies are listed 'Best First'.
Re^2: Net::SSH2 strangeness
by ikegami (Patriarch) on May 18, 2008 at 17:58 UTC

    And $! is for system calls. $ssh2->connect is not a system call, so $! is not appropriate either. Net::SSH2 provides the error method to get error messages. (Although it looks like it croaks for some errors from looking at the source.)

Re^2: Net::SSH2 strangeness
by ysth (Canon) on May 18, 2008 at 18:20 UTC
    (Sorry, I don't know why the connect is complaining about a bad concatenation, although I'm certain someone else will be able to answer that.)
    That's not connect, that's $@ being undef in "cant connect to $hostname: $@ \n".