On Tue, 2008-11-18 at 10:16 -0500, Chas. Owens wrote: > Perl closes all file handles at the end of the program, so the only > reasons to close file handles early are > 1. the program doesn't end (it is a daemon) > 2. you have a limited number of file handles in your environment (or > you consume an unreasonable amount) > 3. a different program will need access to the file soon (a variation > on 1) > 4. you have unlink'ed the file and don't want it to continue to > consume space (at least on UNIX systems) > > One of the nice things about lexical file handles is that they close > automagically when they are garbage collected (normally when they go > out of scope). >
You always explicitly close write files to test for errors. close $fh or die "cannot close file: $!\n"; This is because writing to a file is actually writing to a buffer. The buffer only gets written to the file when it is full or the file is closed. It is very rare that the buffer gets full with the last print. Note that this is a property of the OS and is true for all languages. -- Just my 0.00000002 million dollars worth, Shawn The map is not the territory, the dossier is not the person, the model is not reality, and the universe is indifferent to your beliefs. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/