in reply to use sysread to read non-blocking filehandle
while ($bytes_read) { my $buf; $bytes_read = sysread($out, $buf, $blocksize); ...
Your code leaves the loop as soon as there is nothing to read on a socket.
while( <$fh> ) will read things until it encounters a newline.
In Section
Seekers of Perl Wisdom