When I run the code below I expect to see one print statement every time a file is saved but instead I always see two or more print statements for each save. Does anyone know why this might happen and what I can do to get around it? i only need the last notification.
use Win32::AdvNotify;
my $obj = new Win32::AdvNotify || die "$!\n";
my $thread1 = $obj->StartThread(
Directory => "C:/spot/run",
Filter => LAST_WRITE,
WatchSubtree => Yes ) || die "$!\n";
$thread1->EnableWatch() || die "$!\n";
while($obj->Wait(INFINITE)){
while($obj->Read(\@data)){
for($i=0;$i<=$#data;$i++){
print "$data[$i]->{FileName}\n";
}
}
}
$thread1->Terminate();
$obj->Free;