Linux::Perl::inotify
my $inf = Linux::Perl::inotify->new(); my $wd = $inf->add( path => $path, events => ['CREATE', 'ONLYDIR'] ); my @events = $inf->read(); $inf->remove($wd);
This is an interface to Linuxýs Ûinotifyû feature.
A hash reference of event names to numeric values. The member keys are: ACCESS, MODIFY, ATTRIB, CLOSE_WRITE, CLOSE_NOWRITE, OPEN, MOVED_FROM, MOVED_TO, CREATE, DELETE, DELETE_SELF, MOVE_SELF, UNMOUNT, Q_OVERFLOW, IGNORED, ISDIR, CLOSE, and MOVE.
ACCESS
MODIFY
ATTRIB
CLOSE_WRITE
CLOSE_NOWRITE
OPEN
MOVED_FROM
MOVED_TO
CREATE
DELETE
DELETE_SELF
MOVE_SELF
UNMOUNT
Q_OVERFLOW
IGNORED
ISDIR
CLOSE
MOVE
See man 7 inotify for details of what these mean.
man 7 inotify
Instantiates a new inotify instance.
%OPTS is:
flags - Optional, an array reference of either or both of NONBLOCK and/or CLOEXEC.
flags
NONBLOCK
CLOEXEC
Adds to an inotify instance and returns a watch descriptor. See man 2 inotify_add_watch for more information.
man 2 inotify_add_watch
path - The filesystem path to monitor.
path
events - An array reference of events to monitor for. Recognized events are: ACCESS, MODIFY, ATTRIB, CLOSE_WRITE, CLOSE_NOWRITE, OPEN, MOVED_FROM, MOVED_TO, CREATE, DELETE, DELETE_SELF, MOVE_SELF, CLOSE, MOVE, ALL_EVENTS, ONLYDIR, DONT_FOLLOW, EXCL_UNLINK, MASK_CREATE, MASK_ADD, and ONESHOT.
events
ALL_EVENTS
ONLYDIR
DONT_FOLLOW
EXCL_UNLINK
MASK_CREATE
MASK_ADD
ONESHOT
Reads events from the inotify instance. Each event is returned as a hash reference with members wd, mask, cookie, and name. See man 7 inotify for details about what these mean.
wd
mask
cookie
name
Note that if the underlying inotify object is not set NONBLOCK then this call will block until there is an inotify event to read.
In scalar context this returns the number of events that happened.
An empty return here indicates a read failure; $! will contain the usual information about the failure.
$!
Analogous to man 2 inotify_rm_watch.
man 2 inotify_rm_watch
To install Linux::Perl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Linux::Perl
CPAN shell
perl -MCPAN -e shell install Linux::Perl
For more information on module installation, please visit the detailed CPAN module installation guide.