use strict; my $logfile = "D:\\ChangeNotify.txt"; my $path = "D:\\"; use Win32::ChangeNotify; ChangeWatch(); sub ChangeWatch { #$filter can contain any of the below seperated by a | # #ATTRIBUTES Any attribute change #DIR_NAME Any directory name change #FILE_NAME Any file name change #LAST_WRITE Any change to a file's last write time #SECURITY Any security descriptor change #SIZE Any change in a file's size my $filter = LAST_WRITE; my ($path,$subtree); my $notify = Win32::ChangeNotify->new($path,$subtree,$filter); $notify->wait or warn "Something failed: $!\n"; Notify($path,$subtree); $notify->reset; ChangeWatch(); } sub Notify { my ($path,$subtree)=@_; open(FILE,">>$logfile) or die "could not optn $logfile: $!"; print FILE scalar localtime . "Change Detected at $path $subtree\n"; close FILE; }