Ooh, I didn't know about inotify. It would seem that you can either use it within perl (just keep the script running like a service) or from a command line. I think it really comes down to how often you're expecting new files. And I don't know how the perl module works - its possible you might have to spawn a fork in case another file comes in while you are working.
However, it would seem that that's the tool for the job: http://www.ibm.com/developerworks/linux/library/l-ubuntu-inotify/index.html On Nov 8, 2010 12:04 AM, "Ishwor Gurung" <ishwor.gur...@gmail.com> wrote: > Hi. > > On 8 November 2010 15:46, Chap Harrison <c...@pobox.com> wrote: >> >> On Nov 7, 2010, at 6:47 PM, shawn wilson wrote: >> >>> its Unix, I'd use cron as its probably already running. And do something >>> like: script.pl $(find <path> -type f -print0) Every few seconds. >> >> That looks plenty straightforward enough, except how does one prevent a race condition wherein cron launches another instance of script.pl before the first instance has exclusively grabbed responsibility for loading the newly-arrived files? > > Using a temporary file might be one approach. i.e., in your code, you > write one when processing, exit if it exists in other subsequent code. > This way no code can gobble up each other's resources even though > polling isn't the coolest thing on earth - it does the job. > > If you want to tackle it another way, check out dnotify/inotify syscalls. > > HTH. > > [...] > -- > > Regards > Ishwor Gurung > Key id:0xa98db35e > Key fingerprint:FBEF 0D69 6DE1 C72B A5A8 35FE 5A9B F3BB 4E5E 17B5 > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > >