$buf=''; if($fh->sysread($buf,10240)>0) { $this=$Con{$fh}; $buf=$this->{_}.$buf; while($buf=~/(.*\n)/g) { ${$Con{$fh}}{getline}($fh,$1); last unless $Con{$fh}; # it's possible that the connection can be deleted while there's still something in the buffer } if($Con{$fh}) { ($this->{_})=$buf=~/([^\n\r]*)$/s; if(length($this->{_}) > 10000) { ${$Con{$fh}}{getline}($fh,$this->{_}); ($this->{_})=''; } } } else { done($fh); }