http://www.perlmonks.org?node_id=333656


in reply to Making a perl program look like a regular file on Win32?

You can subscribe to Win32 ChangeNotify messages, which would let you know when a file changed for whatever reason. I'm not sure if this helps in your situation, but it is kinda cool. If you don't have Win32::ChangeNotify installed, you can get it via PPM if you run ActiveState ala "ppm install Win32-ChangeNotify" or from CPAN using "perl -MCPAN -e 'install Win32::ChangeNotify'". Here's some sample code:
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; }
-Vlad