in reply to Re^2: Line by line buffered read
in thread Line by line buffered read
You're not making any sense. Line by line reading (while (<>)) is buffered. sysread, on the other hand, provides no buffering.
If you want to provide your own buffering instead of using Perl's, you could do
my $buf = ''; for (;;) { my $rv = sysread($fh, $buf, BLOCK_SIZE, length($buf)); die("sysread: $!") if !defined($rv); last if !$rv; process_line($1) while s/^([^\n]*\n)//; } process_line($buf) if length($buf);
Update: Fixed problem mentioned by ibm1620 in comment.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Line by line buffered read
by ibm1620 (Hermit) on Feb 25, 2014 at 00:37 UTC |