chanakya has asked for the wisdom of the Perl Monks concerning the following question:
Below is the output of the script without the filename(s) and the session ID.use warnings; use strict; use POE; use POE::Component::DirWatch; POE::Session->create( inline_states => { _start => \&init_watcher, watch_dir => \&watch_dir, }, ); sub init_watcher { my ($kernel, $heap, $session, $sender) = @_[KERNEL, HEAP, SESSION, +SENDER]; warn "Queue 1 starting (session id " . $session->ID . ")"; # watch a directory for this queue $kernel->yield('watch_dir', '/tmp/queue1'); } sub watch_dir { my ($kernel, $heap, $session, $queue) = @_[KERNEL, HEAP, SESSION, + ARG0]; # start watching the directory POE::Component::DirWatch->new( alias => 'dirwatch', directory => $queue, file_callback => \&found_file, interval => 1, ); } sub found_file { my ($kernel, $heap, $session, $sender, $file) = @_[KERNEL, HEAP, S +ESSION, SENDER, ARG1]; # warn "Found '$file' for " . $session->ID . " (from " . $sender-ID + . ")\n"; warn "Found '$file' for $session->ID\n"; } $poe_kernel->run(); exit(0);
Please let me know whats the error. Also let me know if there is a shorter way of doing this.-bash-3.00$ ./dirwatch_test1.pl Queue 1 starting (session id 2) at ./dirwatch_test1.pl line 19. Found '' for ->ID Found '' for ->ID
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Watching a directory with POE::Component::DirWatch
by bingos (Vicar) on Mar 04, 2009 at 17:09 UTC | |
by chanakya (Friar) on Mar 05, 2009 at 15:05 UTC | |
|
Re: Watching a directory with POE::Component::DirWatch
by Anonymous Monk on Mar 04, 2009 at 12:43 UTC | |
by Anonymous Monk on Mar 04, 2009 at 12:46 UTC |