in reply to How to split rows coming from the database
If you want to keep $content as small as possible, you need to do both, splitting and keeping the remainder:
... my $remainder = ''; while (1) { my $buf; my $n = $self->_get_socket()->read_entity_body($buf, 1024); $buf = $remainder . $buf; $remainder = ''; die "can't read response: $!" unless defined $n; last unless $n; if( $buf =~ s!([^\n]+\z)!! ) { $remainder = $1; }; push @response, split (/\n/, $buf); }
You need to keep the incomplete line around until the next newline is read.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to split rows coming from the database
by mocnii (Acolyte) on Nov 08, 2016 at 14:37 UTC | |
by Corion (Patriarch) on Nov 08, 2016 at 14:54 UTC | |
by mocnii (Acolyte) on Nov 09, 2016 at 10:01 UTC |