in reply to How can you check to see if a file handle is already open?
my @handles; for ( 1...31) { open(my $new_fh, ">200712$_"), or die "Could not open $date $!\n"; push @handes, $new_fh; }
The file handles are closed automatically when they go out of scope (and no reference to them exists anymore), so you don't need to close them explictly.
But it's good style to close them anyway, because if your function becomes part of a larger program the opened file handles my suck up resources.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can you check to see if a file handle is already open?
by agent_smith (Scribe) on Jan 16, 2008 at 16:20 UTC | |
by moritz (Cardinal) on Jan 16, 2008 at 16:46 UTC | |
by alexm (Chaplain) on Jan 16, 2008 at 17:58 UTC | |
by mifflin (Curate) on Jan 16, 2008 at 19:58 UTC | |
by Limbic~Region (Chancellor) on Jan 16, 2008 at 20:02 UTC | |
by agent_smith (Scribe) on Jan 16, 2008 at 22:16 UTC | |
by alexm (Chaplain) on Jan 17, 2008 at 09:01 UTC |