Once approach that I can recommend is to open your files inside a scope; once the scope ends, the file handle will automatically be closed. of course, I prefer to explicitly close files handles, but that's just my C background. Something like this:
use autodie;
...
my $config_object;
{
open ( my $config_fh, '<', 'hello.cfg' );
while ( <$config_fh> ) {
.. parse config file ..
$config_object{ $key } = $something;
}
}
# File handle is now out of scope and therefore closed ..
That's a simple example .. but perhaps you can expand on your question .. why do you think that open file handles are causing you problems?
Alex / talexb / Toronto
Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.