in reply to Notification of a new file added to directory

One more thing of note here is that to avoid race conditions you may want to come up with some kind of locking system for the file as they are being written, or you may inadvertantly grab a partially written file for whatever new_file(); does. If you can't control the creation of the files then you may want to do a more complicated test over X time to determine that the file is new _ AND _ that the file is not currently changing before sending to the sub. This second approch still leaves a race situation - but it seems to be a little tighter than just assuming that a new files is not being modified. Also if this is on Win32 you can use one of the API modules on CPAN to open the file with Native locking.

-Waswas
  • Comment on Re: Notification of a new file added to directory