Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Why do we need to close filehandles?

by cdarke (Prior)
on Apr 30, 2011 at 18:14 UTC ( [id://902229]=note: print w/replies, xml ) Need Help??


in reply to Why do we need to close filehandles?

Usually you don't have to (edge cases aside), but it is a good developer's mindset to release resources as soon as possible, so these can be used by other processes, and to reduce the load on the system. That is all resources, not just files.

Personally if I don't close a file it does not feel right - a bit like walking out the door without my trousers on.

Replies are listed 'Best First'.
Re^2: Why do we need to close filehandles?
by JavaFan (Canon) on May 01, 2011 at 16:16 UTC
    Personally if I don't close a file it does not feel right - a bit like walking out the door without my trousers on.
    Yeah, but you still didn't flush.

    Why do feel dirty if you don't close the file yourself (instead of having Perl do it for you), but you're fine with Perl doing the flushing (and syncing) for you? And do you close STDOUT and STDERR?

    I close my handles when I want to inform the user of a possible error - else I let Perl (or the OS) take care of it for me.

      I know what he means; I had to double check the zipper myself until I learned to trust that leaving the scope of the bathroom would ensure it for me.

      Part of the issue might be being used to places where there are no bathroom walls, and bits are deposited just anywhere.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-28 23:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found