benlaw has asked for the wisdom of the Perl Monks concerning the following question:
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
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"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Problem with POE-Component-DirWatch
by runrig (Abbot) on Mar 12, 2006 at 17:24 UTC | |
by sgt (Deacon) on Mar 13, 2006 at 23:36 UTC | |
by benlaw (Scribe) on Mar 14, 2006 at 00:45 UTC | |
Re: Problem with POE-Component-DirWatch
by rcaputo (Chaplain) on Mar 12, 2006 at 19:01 UTC | |
Re: Problem with POE-Component-DirWatch
by insaniac (Friar) on Mar 13, 2006 at 11:24 UTC | |
by runrig (Abbot) on Mar 13, 2006 at 18:03 UTC | |
by benlaw (Scribe) on Mar 13, 2006 at 22:54 UTC | |
by runrig (Abbot) on Mar 13, 2006 at 23:08 UTC |
Back to
Seekers of Perl Wisdom