in reply to Re^2: making sure a file is not currently being written to
in thread making sure a file is not currently being written to

If one of your example functions calls the other, or threads are being used, that might happen, yes. If not, it's not allowed to happen.

From perldoc -f close:

Closes the file or pipe associated with the file handle, returning true only if IO buffers are successfully flushed and closes the system file descriptor.

So if the closing was successfully (and it usually is, unless the disk is full or something really evil happens), the buffer has to be flushed. If not, it's a bug.

  • Comment on Re^3: making sure a file is not currently being written to