my $rv = $handle->sysread($bufline, 4096); $line .= $bufline; while ($rv == 4096) { $rv = $handle->sysread($bufline, 4096); $line .= $bufline unless !$rv; } #### - While there are handles from which to read, - Wait for data to arrive. - Read into the handle's buf. -> Don't forget to handle eof and error. - While the buf has a full command, - Remove the command from the buf. - Process the command. #### my $bufline = ""; my $rv = $handle->sysread($bufline, 4096); $line .= $bufline; #### my $rv = $handle->sysread($line, 4096, length($line));