forever() { while ($buffer =~ /\n/) { $buffer =~ s/(^.*\n)//; $command = $1; process($command); } $sel->can_read(TIMEOUT); $count = $sock->read($newbuffer, 4096); if ($count == 0) { socketicide($sock); last; } $buffer .= $newbuffer; }