in reply to Re: Line by line buffered read
in thread Line by line buffered read

Thanks. I need buffered read for speed.

Replies are listed 'Best First'.
Re^3: Line by line buffered read
by ikegami (Patriarch) on Aug 20, 2010 at 17:06 UTC

    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.

      Please check that regular expression again :) (to be exact, the substitution expression.)