On Wed, Feb 16, 2000 at 12:25:36PM +0100, [EMAIL PROTECTED] wrote:
> I loaded the Event module for Perl for I need to detect when a file is
> written to a determined directory (queue).
Based on that short description, I'd create a timer event that checks
the existence/size of the file using stat().
> I also tried to look
> for examples but did not find them.
Did you see the demo directory? The test suite can also be considered
as an example.
> I tried different things but I cannot make it out,
> I write the following:
>
> use Event qw(loop unloop);
> use Event::Watcher qw(R W);
>
> $ROOT='/work/sadmin/perl/test';
> $QUEUE="$ROOT/queue";
> open(F, $QUEUE) || # open for reading
> die "open: $!";
>
> $w=Event->io(fd=>\*F,
> poll=>'w', # polling for write
> cb=> sub {
> &subroutine;
> unloop;
> print "Unloop\n";
> close(F);
> });
>
> loop();
>
> sub subroutine{
> print "Event in directory: $QUEUE \n";
> }
>
>
> The perl-script just goes into the callback everytime and exits the
> script even without writing any file in the Queue-directory which is
> empty.
I'm confused. Do you expect the file to be created by this script?
--
"May the best description of competition prevail."
via, but not speaking for Deutsche Bank