Created
December 21, 2008 15:39
-
-
Save hakobe/38696 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use POE qw( Sugar::Args ); | |
use File::Modified; | |
use Perl6::Say; | |
my ($command, @files) = @ARGV; | |
my $watcher = File::Modified->new( | |
method => 'mtime', | |
files => \@files, | |
); | |
POE::Session->create( | |
inline_states => { | |
_start => sub { | |
my $poe = sweet_args; | |
$poe->kernel->yield('watch'); | |
}, | |
watch => sub { | |
my $poe = sweet_args; | |
my @changes; | |
eval { @changes = $watcher->changed }; | |
say STDERR "$_ is changed." for @changes; | |
if (@changes) { | |
$watcher->update; | |
system($command); | |
} | |
$poe->kernel->delay(watch => 1); | |
}, | |
}, | |
); | |
POE::Kernel->sig( INT => sub { POE::Kernel->stop } ); | |
POE::Kernel->run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment