in reply to Re: Don't close filehandles (was: To Kill a Meme: while(defined($line = <>)) )
in thread To Kill a Meme: while(defined($line = <>))

Again, getting the return value of a close for a handle that's open for writing is useful. But for something that's open for reading?

I am going to disagree with anyone who states that filehandles should be closed automatically, or who states that automatically closing is a bad idea because of the return value of close, if they don't distinguish the case of having something open for writing, and having something open for reading.

Abigail

  • Comment on Re: Don't close filehandles (was: To Kill a Meme: while(defined($line = <>)) )

Replies are listed 'Best First'.
Ok when open for readning
by ambrus (Abbot) on Nov 06, 2003 at 10:58 UTC

    You are right, I didn't think of that. It is OK to do it when the file is open for read-only.