in reply to open, file handles and memory

As far as I know, that really depends on the operating system and how it handles open file handles. However, most of the time it will buffer the file--read in one line at a time. I wouldn't worry about it.

Just don't do something like this:

open(FILE, "somefile") or die $!; my @log = <FILE>; # read entire file into RAM close(FILE); foreach my $line (@log) { # do stuff to $line }
That will definitely clutter up your machine's memory!

On the other hand, if you have a gigabyte of RAM and you WANT to load the entire file instead of using slow disk accesses, knock yourself out. =)

Replies are listed 'Best First'.
Re: Re: open, file handles and memory
by Viking (Beadle) on Jan 13, 2001 at 17:58 UTC
    That's what I want to avoid, speed isn't an issue (well within reason), having my server grind to a halt because of it running out of memory would be!! :)