AnyEvent::Inotify::Simple - monitor a directory tree in a non-blocking way
use AnyEvent::Inotify::Simple; use EV; # or POE, or Event, or ... my $inotify = AnyEvent::Inotify::Simple->new( directory => '/tmp/uploads/', wanted_events => [ qw(create move) ], event_receiver => sub { my ($event, $file, $moved_to) = @_; given($event) { when('create'){ say "Someone just uploaded $file!" } }; }, ); EV::loop;
This module is a wrapper around Linux::Inotify2 that integrates it with an AnyEvent event loop and makes monitoring a directory simple. Provide it with a directory, event_receiver (AnyEvent::Inotify::Simple::EventReceiver), and an optional coderef filter and/or optional array ref wanted_events, and it will monitor an entire directory tree. If something is added, it will start watching it. If something goes away, it will stop watching it. It also converts IN_MOVE_FROM and IN_MOVE_TO into one virtual event.
directory
event_receiver
filter
wanted_events
IN_MOVE_FROM
IN_MOVE_TO
Someday I will write more, but that's really all that happens!
None! Create the object, and it starts working immediately. Destroy the object, and the inotify state and watchers are automatically cleaned up.
Forks welcome!
http://github.com/jrockway/anyevent-inotify-simple
Jonathan Rockway <jrockway@cpan.org>
<jrockway@cpan.org>
Current maintainer is Rob N ★ <robn@robn.io>
<robn@robn.io>
Copyright 2009 (c) Jonathan Rockway. This module is Free Software. You may redistribute it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in '★'. Assuming UTF-8
To install AnyEvent::Inotify::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnyEvent::Inotify::Simple
CPAN shell
perl -MCPAN -e shell install AnyEvent::Inotify::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.