biswanath_c has asked for the wisdom of the Perl Monks concerning the following question:


Hi!

I need some help.

I am trying to write a perl script that'll monitor the changes made to a directory; i am trying to schedule it on a Windows server using the task scheduler.

i would like the task to:

- start at 7 am everyday, send out an email to a group(sending the email is not the issue for me; i've coded that part fine...)

- listen for any directory changes using Win32::ChangeNotiy

- stop at 3PM and send out an email to a group again

Now, i have a couple of questions here

- is there an alarm event in perl? something like "it is 3PM now!" event that my code can listen to and then wake up from listening to directory change and send out an email? (I believe i cannot give a timeout in ChangeNotify->Wait method that'll ask the code to wake up at 3PM!!)

- if there is an alarm event, can my code listen to both the "directory change" event and the "it is 3PM" event at the same time and then handle whichever occurs first?


Thanks

Replies are listed 'Best First'.
Re: Question in Win32::ChangeNotify...
by pc88mxer (Vicar) on Jul 02, 2008 at 17:46 UTC
    Just specify a timeout on your wait call so you can periodically check the time:
    my $notify = ...wait notify object... while (1) { my $result = $notify->wait(60*1000); # timeout = 1 minute ...process $result... ...check for 3pm... }
    Update: fixed timeout value
      60*60*1000 is 1 hour. You want 60*1000 for 1 minute.

        Thanks a lot for the reply. The timeout worked!

        but would anyone know if there's any 'alarm' event that i could use in PERL?

        thanks