File: event

package info (click to toggle)
liblinux-inotify2-perl 1:2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 156 kB
  • sloc: perl: 147; makefile: 3
file content (22 lines) | stat: -rwxr-xr-x 623 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl

# example for Event integration

use Event;
use Linux::Inotify2;

my $inotify = new Linux::Inotify2;

Event->io (fd => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll });

$inotify->watch ("/tmp", IN_ALL_EVENTS, sub {
   my $e = shift;
   printf "events for <%s>:%d received: %x\n", $e->fullname, $e->cookie, $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::loop;