Mercurial > org-tools
comparison 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 |
comparison
equal
deleted
inserted
replaced
5:4824087ce1f2 | 6:5370428e673e |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 use Linux::Inotify2; | |
4 use AnyEvent; | |
5 | |
6 | |
7 my $inotify = new Linux::Inotify2 | |
8 or die "unable to create new inotify object: $!"; | |
9 | |
10 | |
11 @org_files = glob("./org/*.org"); | |
12 | |
13 $" = "\n"; | |
14 print "@org_files"; | |
15 | |
16 | |
17 foreach(@org_files){ | |
18 # add watchers | |
19 $inotify->watch ($_, IN_MODIFY, sub | |
20 { | |
21 my $e = shift; | |
22 my $name = $e->fullname; | |
23 print "$name was modified\n" if $e->IN_MODIFY; | |
24 ` | |
25 | |
26 }); | |
27 | |
28 | |
29 | |
30 | |
31 } | |
32 | |
33 | |
34 | |
35 | |
36 # integration into AnyEvent (works with EV, Glib, Tk, POE...) | |
37 my $inotify_w = AnyEvent->io | |
38 ( | |
39 fh => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll } | |
40 ); | |
41 | |
42 # manual event loop | |
43 1 while $inotify->poll; |