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

Re: [MacPerl] Read Speed





On Sat, 13 Dec 1997, Jon S. Jaques wrote:

> On my PowerBook 540 w/12mb ram, I get an 'Out of memory!' error on the
> following, while reading in a 5mb ASCII file:
> 
> open(IN,  "$hostname:Desktop Folder:allfiles.txt");
> open(OUT, ">$hostname:Desktop Folder:allfiles2.txt");
> 
> @LINES = <IN>;
> print OUT join(' ', @LINES);
> 
> close IN;
> close OUT;

Why does everyone always load the entire file into memory?

Something like

while (<IN>)
{ print OUT "chop($_) ";}

should be a lot more effective (if chop is what i'm thinking it is...)

-Johan



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch