in reply to Correct way to use Net:SSH2 module
When I had that issue, I wrote an wrapper for executing commands that always followed the command with echo'ing "COMMAND_IS_DONE" or somesuch. Then keep reading until you see your marker.
Update: wow...no "echo"?? It's often a shell builtin. My condolences. But I think you could satisfactorily uniquify a "COMMAND_IS_DONE" string by adding a pid or other random digits/characters...
In Section
Seekers of Perl Wisdom