Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Multiplatform event handling module?

by rastoboy (Monk)
on Aug 12, 2009 at 02:29 UTC ( #787816=perlquestion: print w/replies, xml ) Need Help??

rastoboy has asked for the wisdom of the Perl Monks concerning the following question:

Is there a good, well used, multiplatform event detection module available? I'd like to be informed when a new file shows up in a particular directory. The idea of polling just seems *wrong* somehow. My searches of cpan have revealed multiple options, but I just don't know the good from the bad. My main platform is Linux, so something that works very well there would be ideal, but it would also be nice if it could be used on FreeBSD or OSX. Any input would be greatly appreciated!

Replies are listed 'Best First'.
Re: Multiplatform event handling module?
by thunders (Priest) on Aug 12, 2009 at 03:13 UTC
    For linux there is Linux::Inotify2 it interfaces with a kernel-level event notification subsystem. A potential multiplatform solution is File::Monitor a quick look at that module suggests you need to call a scan() method manually for polling.
      I know you didn't mention Win32, but this looks like an equivalent mechanism on windows. I don't think there's a direct perl interface to this, though it should be fairly straightforward to implement.
Re: Multiplatform event handling module?
by thunders (Priest) on Aug 12, 2009 at 14:30 UTC

    I looked into BSD and OSX and it looks like kqueue is the common way to do event notifications. There is a thin wrapper around this utility called IO::KQueue on cpan.

    Here is some C source code I found which uses kqueue and kevent for directory monitoring, hopefully that would be adaptable.

    MacOSX also recently added FSEvents but that's only available from 10.5(Leopard) on.

Re: Multiplatform event handling module?
by pileofrogs (Priest) on Aug 12, 2009 at 17:10 UTC

    I have no idea if POE is appropriate or not, but you may want to have a look at it. It's all about portable event handling. I've never used it, but I've been peering at it from time to time.


      Thanks a bunch y'all! That POE looks quite promising--I'll post a followup with my findings after trying all your suggestions.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://787816]
Approved by planetscape
Front-paged by Arunbear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2019-06-17 23:37 GMT
Find Nodes?
    Voting Booth?
    Is there a future for codeless software?

    Results (80 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!