perl some.pl
Logged in to 192.168.0.18
Use of uninitialized value in pattern match (m//) at some.pl line 33.
testing is not running
Thread 2 terminated abnormally: SSHConnectionAborted at total.pl line +25
Use of uninitialized value in pattern match (m//) at some.pl line 33.
b is not running
Thread 3 terminated abnormally: SSHConnectionAborted at total.pl line +25
Use of uninitialized value in pattern match (m//) at some.pl line 33.
c is not running
Logged in to 192.168.0.19
Segmentation fault

I suspect your main problem is that you're trying to use the same instance of the SSH connection in all threads. Creating a new thread doesn't automagically also create a new independent duplicate of the connection (socket, server-side process, and all), so the SSH will probably get mildly confused when multiple clients are talking simultaneously on the same line...

I am able to achieve this without threads and its working fine except that it is taking much time in a foreach loop. So, I would like to add threads to this.

I would be hard-pressed to be convinced that “adding threads to” such an algorithm that is right now “working fine(!)” will actually make it either more reliable, or faster. Threading always divides time, while adding considerable complication. So, all kinds of Danger, Will Robinson! alarm bells are going off in my head. What is the procedure that is being performed by this loop that is taking too much time? What is the source of the delay?

Don’t “diddle” code to make it faster: find a better algorithm.– Kernighan and Plauger; The Elements of Programming Style.

When putting a smiley right before a closing parenthesis, do you:

Use two parentheses: (Like this: :) )
Use one parenthesis: (Like this: :)
Reverse direction of the smiley: (Like this: (: )
Use angle/square brackets instead of parentheses
Use C-style commenting to set the smiley off from the closing parenthesis
Make the smiley a dunce: (:>
I disapprove of emoticons
Other