The listener: receive a chunk of data 

sub handle_data {
    my($self, $sock) = @_;

    my $key = refaddr($sock);

    my $buf;
    my $bytes = sysread $sock, $buf, 4096;
    if($bytes) {
        $self->{$key}->{buf} .= $buf;
        if($self->{$key}->{buf} =~ m{^(.*?)\x0A\x0A\z}s) {
            $self->run_command($1);
            $self->{$key}->{buf} = '';
        }
    }
    else {
        $self->{_selector}->remove($sock);
        $sock->close;
        delete $self->{$key};
    }
}