in reply to Re: To Kill a Meme: while(defined($line = <>))
in thread To Kill a Meme: while(defined($line = <>))
A plea to not close a filehandle because Perl will close it for you?
Actually, this is one thing I always advise people to do - use lexical filehandles in tight scopes, and let their scoping take care of closing. That's much cleaner and easier to maintain than package filehandles.
It's related to the distinction between in control flow GOTO-driven and structured programs: you don't have to figure out the temporal sequence of code to understand where a filehandle comes into play and when its lifecycle ends, all you need is to look at the spatial layout of the source.
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Don't close filehandles (was: To Kill a Meme: while(defined($line = <>)) )
by BrowserUk (Patriarch) on Nov 03, 2003 at 20:02 UTC | |
by Abigail-II (Bishop) on Nov 03, 2003 at 21:38 UTC | |
by BrowserUk (Patriarch) on Nov 03, 2003 at 21:59 UTC | |
by Abigail-II (Bishop) on Nov 03, 2003 at 22:08 UTC | |
|
Re: Don't close filehandles (was: To Kill a Meme: while(defined($line = <>)) )
by ambrus (Abbot) on Nov 05, 2003 at 12:06 UTC | |
by Abigail-II (Bishop) on Nov 05, 2003 at 12:40 UTC | |
by ambrus (Abbot) on Nov 06, 2003 at 10:58 UTC | |
by Aristotle (Chancellor) on Nov 06, 2003 at 20:30 UTC |