in reply to FileHandle objects as data members of another object
Personally, I don't often use FileHandle, IO::File or similar packages to open and close filehandles. I'm content to use Perl's built-in open and close functions and -- since I've begun to drink the PBP kool-aid -- I always use lexically-scoped filehandles. So I'm always very conscious of the scope in which I open and close filehandles and would never open a handle without closing it in the same scope.
One of the good points of lexical filehandles is that just like IO::Handle objects (as xdg points out), you do not need to explicitly close them in the same scope, because they will automatically be closed when going out of it, or more precisely when the last reference to them will evaporate. Which is not meant to imply that you don't have to do so, because in some situations you will: just not always, and not most often, at least with regular files.
|
|---|