ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Linux-Inotify2/eg/simple
Revision: 1.2
Committed: Tue Aug 23 02:22:23 2005 UTC (21 years ago) by root
Branch: MAIN
CVS Tags: rel-1_1, rel-1_0, rel-1_2, rel-2_2, rel-2_3, rel-2_0, rel-2_1, rel-1_01, rel-0_8, rel-1_21, rel-1_22, HEAD
Changes since 1.1: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/opt/bin/perl
2    
3 root 1.2 # very simple example without further modules
4 root 1.1
5     use Linux::Inotify2;
6    
7     my $inotify = new Linux::Inotify2;
8    
9     $inotify->watch ("/etc/passwd", IN_ACCESS | IN_MODIFY, sub {
10     my $e = shift;
11     printf "events for <%s> received: %s\n", $e->fullname, $e->mask;
12     print "$e->{w}{name} was accessed\n" if $e->IN_ACCESS;
13     print "$e->{w}{name} was modified\n" if $e->IN_MODIFY;
14     print "$e->{w}{name} is no longer mounted\n" if $e->IN_UNMOUNT;
15     print "events for $e->{w}{name} have been lost\n" if $e->IN_Q_OVERFLOW;
16    
17     $e->w->cancel;
18     });
19    
20     $inotify->poll;
21