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.

-- 
Affijn, Ruud

"Gewoon is een tijger."



-- 
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