http://qs321.pair.com?node_id=545917

use Win32::ChangeNotify; my $Path = 'C:\\QA'; my $Events = 'FILE_NAME'; my $notify = Win32::ChangeNotify->new($Path,0,$Events); my %dir; @dir{glob("$Path\\*")} = undef; while (1) { print STDERR 'Waiting...'; $notify->wait or warn "Wait failed: $!\n"; $notify->reset(); my @files = glob("$Path\\*"); my @added = grep {!exists $dir{$_}} @files; print "Filenames added: @added\n" if @added; delete @dir{@files}; my @removed = keys %dir; print "Filenames removed: @removed\n" if @removed; undef %dir; @dir{@files} = undef; } $notify->close();