#!/opt/bin/perl # exmaple for Event integration use Event; use Linux::Inotify2; my $inotify = new Linux::Inotify2; Event->io (fd => $inotify->fileno, prot => 'r', cb => sub { $inotify->poll }); $inotify->watch ("/etc/passwd", IN_ACCESS | IN_MODIFY, sub { my $e = shift; printf "events for <%s> received: %s\n", $e->fullname, $e->mask; print "$e->{w}{name} was accessed\n" if $e->IN_ACCESS; print "$e->{w}{name} was modified\n" if $e->IN_MODIFY; print "$e->{w}{name} is no longer mounted\n" if $e->IN_UNMOUNT; print "events for $e->{w}{name} have been lost\n" if $e->IN_Q_OVERFLOW; Event::unloop; }); Event::loop;