[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] beauty vs. brains



At 21:26 15/03/00, Randal L. Schwartz wrote:
> >>>>> "Nathan" == Nathan Torkington <gnat@frii.com> writes:
>
>Nathan> Jeff Pinyan writes:
> >> read(FILE, $file, -s FILE);
>
>Nathan> Oooh, very cute.  So does this work on Windows?  -s returns the number
>Nathan> of bytes in the file, but does read() want a character count or a byte
>Nathan> count?
>
>You don't even need the size.
>
>   read FILE, $file, 1e20
>
>Adjust the upper bound to suit.  It can't read more than it is. :)

Sorry about this but I get

fergal@zeus:~> perl -e 'open(FILE, "conc");read(FILE, $file, 1e8);print $file'

works fine

fergal@zeus:~> perl -e 'open(FILE, "conc");read(FILE, $file, 1e9);print $file'
Out of memory!

fergal@zeus:~> perl -e 'open(FILE, "conc");read(FILE, $file, 1e10);print $file'
Negative length at -e line 1.


and file conc is only 748 bytes. It looks like it tries to allocate a 
buffer big enough before doing it,

Fergal



==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe