Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: A way to report open file handles a Perl script has open?

by talexb (Chancellor)
on Apr 04, 2017 at 18:15 UTC ( [id://1187030]=note: print w/replies, xml ) Need Help??


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:

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1187030]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-18 11:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found