Hi Monks,
I am trying to monitor directory through POE, I download POE-Component-DirWatch and try to monitor win32 directory
c:\> dirwatch.pl C:\temp\
however, there is no response whatever I add any file
#! perl -w
#
#$Id: dirwatch,v 1.3 2002/07/04 20:13:24 eric Exp $
use strict;
use POE qw(Component::DirWatch);
my $dir = shift or die "usage: $0 directory\n";
my $intv = shift || 1;
print "$dir\n";
POE::Session->create(
inline_states => {
_start => \&_start,
},
args => [ $dir, $intv ],
);
$poe_kernel->run();
exit 0;
####################
sub _start
{
my ($kernel, $dir, $intv, $rex) = @_[KERNEL, ARG0..ARG2];
POE::Component::DirWatch->spawn(
Directory => $dir,
PollInterval => $intv,
Filter => sub { $_[0] =~ /\.gz$/ && -f $_[1] },
Callback => \&gotfile,
);
}
####################
sub gotfile
{
print "$dir\n";
my ($file, $pathname) = @_[ARG0, ARG1];
print scalar(localtime), " $file ($pathname)\n";
}