On Tue, Nov 18, 2008 at 10:05, Raymond Wan <[EMAIL PROTECTED]> wrote: > > Hi Lauri, > > Good to hear -- if the file is small enough to be read in entirely, that is > what I would do. If you need to add in another loop to output a third file, > then you can just add it in easily to make another pass. > > One suggestion which makes no difference to your program and some people > might disagree with me is to move the "close" up so that you close the file > pointer as soon as you know you don't need it anymore. I use to close it at > the end, but when my scripts became pages long, I sometimes forgot... :-) > And it minimizes the time that you keep it open. But it won't make a big > difference for your script...just a suggestion. snip
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). -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
