Mercurial > org-tools
view auto-weave.pl @ 7:ce96610fe058
perl script is amazing
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 24 Oct 2011 09:41:38 -0700 |
parents | 5370428e673e |
children | 73beed20f7de |
line wrap: on
line source
1 #!/usr/bin/perl3 use Linux::Inotify2;4 use AnyEvent;7 my $inotify = new Linux::Inotify28 or die "unable to create new inotify object: $!";11 @org_files = glob("./org/*.org");13 $" = "\n";14 print "@org_files";17 foreach(@org_files){18 # add watchers19 $inotify->watch ($_, IN_MODIFY, sub20 {21 my $e = shift;22 my $name = $e->fullname;23 print "$name was modified\n" if $e->IN_MODIFY;24 `weave $name`;25 });30 }35 # integration into AnyEvent (works with EV, Glib, Tk, POE...)36 my $inotify_w = AnyEvent->io37 (38 fh => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll }39 );41 # manual event loop42 1 while $inotify->poll;