Created
February 13, 2012 12:07
-
-
Save sugar84/1816344 to your computer and use it in GitHub Desktop.
Example of AnyEvent::Filesys::Notify
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
#!/usr/bin/env perl | |
use common::sense; | |
use AnyEvent::Filesys::Notify; | |
use AnyEvent; | |
my $src = "/my/proj/path/htdocs"; | |
my $dst = "/var/www/html"; | |
my $cv = AnyEvent->condvar; | |
my $notifier = AnyEvent::Filesys::Notify->new( | |
dirs => [$src], | |
interval => 0.5, | |
filter => sub { | |
my $item = shift; | |
return $item =~ /\.(css|js)$/ && $item !~ /svn/; | |
}, | |
cb => sub { | |
my @events = @_; | |
for my $event (@events) { | |
next if $event->type ne 'modified'; | |
my $item = $event->path; | |
if ($item =~ /css$/) { | |
system("cp $item ${dst}/css"); | |
} | |
elsif ($item =~ /js$/) { | |
system("cp $item ${dst}/js"); | |
} | |
} | |
}, | |
); | |
$cv->recv; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment