So, you mean to say keep the thread that will do all like creating a SSH reference, calling function and what not for each server....?
No. I meant rather than create the Net::SSH::Expect object in the loop and then pass it into the thread, pass the information required to create the session into the thread create the session there.
However, whether that would actually work is predicated upon the module being thread safe and capable of handling concurrent sessions to different servers, which I strongly suspect is not the case, though I do not know for sure and cannot test it.
The bottom line is I do not think that you will be able to use threading and with Net::SSH::Expect. I would suggest that you contact the author and ask him if the module is thread-safe.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.