On Fri, Feb 07, 2003 at 12:25:39AM +0100, Louis Pouzin wrote: > Thank you Ronald. Your explanations bring much clarification. > > On Thu, 6 Feb 2003 10:00:16 -0500, Ronald J Kimball wrote: > > > An eof without an argument uses the last file read as argument. > > >You have not read from any files at this point in your script, so calling > >eof without an argument is not useful. Perhaps you meant to call eof(IN) > >instead. > > Quite right. I thought opening the file was enough. Indeed, eof(IN) is the correct >thing. > > >perldoc -f eof: > >And perldoc -f read: > > Where did you get this ? I have tried on a unix server; it doesn't know the perldoc >command. Where is it located ? >
It's part of the standard Perl installation. However, you can always find the Perl documentation (for various versions of Perl) at http://www.perldoc.com/ > >But, instead of read(), you can actually read blocks with <>, by setting $/ > > to a reference to an integer: > > >$/ = \100000; > > >while (<IN>) { > > $k++; > >} > > That's neat. I didn't know of this feature. I tried it several times, but > unfortunately, I got "out of memory" on each run. More disturbing is the > fact that it happened as well with values of 10000 and 1000. > > The file is 3509313 bytes, bigger than my MacPerl can swallow. However, I > had no trouble with 100000 byte blocks and the "read" command. I even > tried 1M blocks without harm. Does this mean that the reading or > buffering process is quite different when using <> ? Or is it MacPerl > 5.20r4, which I'm still using ? Oh. I think that this feature was added in perl5.005-something or other. MacPerl 5.20r4 is based off of perl5.004 I think. So, stick with read() and call eof(IN) or use the return value from read(). Ronald