in reply to Problem with POE-Component-DirWatch

hey...

You're problem is really obvious:

Filter => sub { $_[0] =~ /\.gz$/ && -f $_[1] },
remove this (or make a better filter) from your code, and it will work better ;-)
I've tested the above code in Windows and Linux, without the Filter-line, all works well :)

hth

to ask a question is a moment of shame
to remain ignorant is a lifelong shame

Replies are listed 'Best First'.
Re^2: Problem with POE-Component-DirWatch
by runrig (Abbot) on Mar 13, 2006 at 18:03 UTC
    I tested the code also (how did you test it?). While the program was running, I created a file with a name ending in ".gz", and the module did not detect it. In debugging the module, I found that the same list of files was being processed over and over, without the new file ever being in the list, BEFORE the filtering even took place. I suspect it's a difference in the way rewinddir behaves on Win32 vs. *nix (instead of opening the directory with opendir, it just rewinds the previously opened directory handle and then reads the files again from the same handle). And if your test was valid, then maybe it also depends on the version of Windows and/or perl?
      Thanks for all monks! I try to modify the filter to
      Filter => sub { $_[0] =~ /.txt$/ && -f $_[1] },
      then I re-run, it print the following message repeatly until i del file test.txt manually
      Tue Mar 14 06:41:06 2006 test.txt (C:\temp\test.txt) Tue Mar 14 06:41:06 2006 test.txt (C:\temp\test.txt)
      however I try paste new_test.txt to c:\temp\, it seems no response (May be the same with runrig) my perl version is "v5.8.4 built for MSWin32-x86-multi-thread"
        Find the rewind line in the poll subroutine in the module and replace it with:
        # rewind to directory start # $heap->{DirHandle}->rewind; $heap->{DirHandle}->close; $heap->{DirHandle}->open($heap->{Directory}) or croak "Can't open $heap->{Directory}: $!\n";
        The module and your code seem to work with the above changes. (I've emailed the module author with a link to this thread).