File::Hotfolder - recursive watch directory for new or modified files
my $hf = File::Hotfolder->new( watch => '/my/input/path', delete => 1 callback => sub { my $path = shift; # absolute path ... return should_delete($path) ? 1 : 0; }, );
This module uses Linux::Inotify2 to recursively watch a directory for new or modified files. A callback is called on each file with its absolute path.
Deletions and new subdirectories are not reported but new subdirectories will be watched as well.
Base directory to watch
Callback for each new or modified file. The callback is not called during a write but after a file has been closed.
Delete the modified file if a callback returned a true value (disabled by default).
use File::Hotfolder; use File::Spec; my $root = @ARGV[0]; my $hf = File::Hotfolder->new( watch => $root, delete => 0, callback => sub { my $path = shift; print File::Spec->abs2rel( $path, $root ) . "\n"; } ); 1 while $hf->poll;
File::ChangeNotify, Filesys::Notify::Simple, AnyEvent::Inotify::Simple
Copyright Jakob Voss, 2015-
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install File::Hotfolder, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::Hotfolder
CPAN shell
perl -MCPAN -e shell install File::Hotfolder
For more information on module installation, please visit the detailed CPAN module installation guide.