Follow up to previous question...
I got a great script from Clockwatcher and want to modify it so that it returns not just files added and deleted to the directory, but if existing files have changed since the initial scan. I need the name of the file that changed as a return value,
Here is what I started with:
use File::Monitor;
my $monitor = File::Monitor->new();
$monitor->watch( {
name => 'c:/logs',
callback => \&SomethingHappened,
files => 1
}
);
$monitor->scan();
for ($i=0; $i < 10; $i++)
{
$monitor->scan();
sleep 10;
}
sub SomethingHappened
{
my ($name, $event, $change) = @_;
my @adds = $change->files_created;
my @dels = $change->files_deleted;
print "Added: ".join("\nAdded: ", @adds)."\n" if @adds;
print "Removed: ".join("\nRemoved: ", @dels)."\n" if @dels;
}
I have tried variations of the line:
my @mods = $change(mtime); but haven't had any luck.
Start Free Trial