use strict; use warnings; use Win32::ReadDirectoryChangesW; my $path = 'c:/directory'; my $subtree = 1; my $filter = FILE_ACTION_ADDED | FILE_ACTION_MODIFIED; my $rdc = Win32::ReadDirectoryChangesW->new(path => $path, subtree => 1, filter => $filter); my @results = $rdc->read_changes; while (scalar @results) { my ($action, $filename) = splice(@results, 0, 2); if ($action == FILE_ACTION_ADDED || $action == FILE_ACTION_MODIFIED) { # perform your backup here } }