In <20070710192114.167$>
writes:
>kj <> wrote:
>> I've rtfm'd this question but I still can't figure out why one
>> would prefer Perl's read over Perl's sysread, or viceversa.
>"read" can be used with readline (aka "<$fh>") , while sysread generally
>can't be, at least not without introducing strange behavior.
Hmmm... I sense that I'm missing something important here...
The reason I'm fussing over read and sysread in the first place is
that I wanted to speed up some code that currently uses readline
to get data from a huge file (about 1.5GB). I thought that I could
speed things up by reducing the number of disk reads; i.e. by
periodically reading, say, 4096 bytes to a buffer in memory and
feeding lines to the program from this buffer...
But, reading your reply between the lines a bit, I'm now guessing
that maybe Perl already does precisely this behind the scenes even
when one uses readline, meaning that I would not be gaining much
speed, and may even lose some, by switching from my naive <$fh>
implementation to one using read or sysread. Did I get this right?
TIA!
kj
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.