Skip to content

Instantly share code, notes, and snippets.

@hakobe
Created December 21, 2008 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hakobe/38696 to your computer and use it in GitHub Desktop.
Save hakobe/38696 to your computer and use it in GitHub Desktop.
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