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.
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.
| [reply] [Watch: Dir/Any] |
|
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.
| [reply] [Watch: Dir/Any] |
|