> Bryan Harris schreef:
> 
>> If I'm reading in many-megabyte files, is it considered to be more
>> efficient to read it into an array, then loop over the array?
> 
> Line-by-line is fine.
> 
> Your Operating System will read from disk in blocks, so stop believing
> that each line needs a disk access.
> (unless each line is about the size of a block, but blocks can easily be
> 2 MB)
> 
> 
>> I realize the [for-loop] will use more memory, but what's a few
> megabytes
>> in today's computers?
> 
> That can really byte, when there are only a few megabytes left to spare.
> You don't want a memory fight in your system, because that slows down
> all processes considerably, because it will start swapping memory blocks
> to disk for a moment, then read them back in, etc.


I figured the OS would load the file in blocks, but I thought the blocks
might only be 12k or something like that.

I am surprised at the levels of concern over memory reading in <20 MB files.
Don't most people have 1+ GB now?  I've got 2...  I'm just surprised that
using at most 1% of my total ram would be a concern.

Thanks for the responses, I'll do the line by line.

- B




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to