I dont think this is the way. $ssh->login doesnt seem to return anything I can use. The 'new' method returns an object, can I do anything with this once Ive called a login ? Stuck.
Originally I used IO::SOCKET to check if port 22 was even there. But that didn't check if login worked or not. Since then I've been wrapping $ssh->new and $ssh->login inside eval which seemed to do the trick. I even logged which servers it failed on so I could check later on. You might want to give that a try. It seems to work pretty good.