in reply to Re: Why do we need to close filehandles?
in thread Why do we need to close filehandles?

Bingo!   There’s a solid technical reason for paying close attention to file-handles ... buffering.   Until a file-handle is closed, it is possible that there’s some data out there which has not been written to disk.   Other applications will not see that data yet; nor will this application, necessarily, if it opens a second handle to the same file.   (Which it is, of course, free to do.)

Obviously, the system will wipe your a*s ... clean up after you even if you don’t, but writing to a file is an action that you need to explicitly bring to a close.   Reading from the file is much more forgiving.

Replies are listed 'Best First'.
Re^3: Why do we need to close filehandles?
by JavaFan (Canon) on May 01, 2011 at 16:08 UTC
    There’s a solid technical reason for paying close attention to file-handles ... buffering.
    Well, you can just flush the handle; there's no need to close it. And if you do things in a logical way, you either read/write using buffered I/O, or you read/write using unbuffered I/O. In either case, you should be fine.