Mercurial > org-tools
diff 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 |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/auto-weave.pl Mon Oct 24 09:29:17 2011 -0700 1.3 @@ -0,0 +1,43 @@ 1.4 +#!/usr/bin/perl 1.5 + 1.6 +use Linux::Inotify2; 1.7 +use AnyEvent; 1.8 + 1.9 + 1.10 +my $inotify = new Linux::Inotify2 1.11 + or die "unable to create new inotify object: $!"; 1.12 + 1.13 + 1.14 +@org_files = glob("./org/*.org"); 1.15 + 1.16 +$" = "\n"; 1.17 +print "@org_files"; 1.18 + 1.19 + 1.20 +foreach(@org_files){ 1.21 +# add watchers 1.22 +$inotify->watch ($_, IN_MODIFY, sub 1.23 +{ 1.24 + my $e = shift; 1.25 + my $name = $e->fullname; 1.26 + print "$name was modified\n" if $e->IN_MODIFY; 1.27 + ` 1.28 + 1.29 +}); 1.30 + 1.31 + 1.32 + 1.33 + 1.34 +} 1.35 + 1.36 + 1.37 + 1.38 + 1.39 +# integration into AnyEvent (works with EV, Glib, Tk, POE...) 1.40 +my $inotify_w = AnyEvent->io 1.41 + ( 1.42 + fh => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll } 1.43 + ); 1.44 + 1.45 + # manual event loop 1.46 +1 while $inotify->poll;