in reply to A way to report open file handles a Perl script has open?
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:
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?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 ..
|
|---|