Well, the truth it is a little tricky:
in reply to Re^3: Communication between Windows and Linux via Perl
in thread Communication between Windows and Linux via Perl
First, you should loop until the eof method from Net::SSH2::Channel returns true.
In order to not have a busy loop, you can use sock (that returns the socket used for the SSH connection) and block_directions (which tells one if Net::SSH2 needs to write or read from that socket) combined with select to wait for some activity on the SSH socket.
Or you can just use Net::SSH::Any that will do all of that for you (or you can also look at its source code for inspiration).