annotate auto-weave.pl @ 6:5370428e673e

experimenting with a perlscript for weaving
author Robert McIntyre <rlm@mit.edu>
date Mon, 24 Oct 2011 09:29:17 -0700
parents
children ce96610fe058
rev   line source
rlm@6 1 #!/usr/bin/perl
rlm@6 2
rlm@6 3 use Linux::Inotify2;
rlm@6 4 use AnyEvent;
rlm@6 5
rlm@6 6
rlm@6 7 my $inotify = new Linux::Inotify2
rlm@6 8 or die "unable to create new inotify object: $!";
rlm@6 9
rlm@6 10
rlm@6 11 @org_files = glob("./org/*.org");
rlm@6 12
rlm@6 13 $" = "\n";
rlm@6 14 print "@org_files";
rlm@6 15
rlm@6 16
rlm@6 17 foreach(@org_files){
rlm@6 18 # add watchers
rlm@6 19 $inotify->watch ($_, IN_MODIFY, sub
rlm@6 20 {
rlm@6 21 my $e = shift;
rlm@6 22 my $name = $e->fullname;
rlm@6 23 print "$name was modified\n" if $e->IN_MODIFY;
rlm@6 24 `
rlm@6 25
rlm@6 26 });
rlm@6 27
rlm@6 28
rlm@6 29
rlm@6 30
rlm@6 31 }
rlm@6 32
rlm@6 33
rlm@6 34
rlm@6 35
rlm@6 36 # integration into AnyEvent (works with EV, Glib, Tk, POE...)
rlm@6 37 my $inotify_w = AnyEvent->io
rlm@6 38 (
rlm@6 39 fh => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll }
rlm@6 40 );
rlm@6 41
rlm@6 42 # manual event loop
rlm@6 43 1 while $inotify->poll;