File::Monitor::Lite(3pm) | User Contributed Perl Documentation | File::Monitor::Lite(3pm) |
File::Monitor::Lite - Monitor file changes
use File::Monitor::Lite; my $monitor = File::Monitor::Lite->new ( in => '.', name => '*.html', ); while ($monitor->check() and sleep 1){ my @deleted_files = $monitor->deleted; my @modified_files = $monitor->modified; my @created_files = $monitor->created; my @observing_files = $monitor->observed; `do blah..` if $monitor->anychange; }
This is another implementation of File::Monitor. While File::Monitor cannot detect file creation (unless you declare file name first), I use File::Find::Rule to rescan files every time when $monitor->check() is executed. To use this module, just follow synopsis above.
Currently one cannot change file observing rules. To do so, create another monitor object with new rules.
$m1=File::Monitor::Lite->new( name => '*.html', in => '.', ); $m1->check(); #blah... $m2=File::Monitor::Lite->new( name => '*.css', in => '.', ); $m2->check(); #blah...
my $monitor = File::Monitor::Lite->new( in => '.', name => '*.mp3', );
The syntax is inherited from File::Find::Rule. It will applied on File::Find::Rule as
File::Find::Rule ->file() ->name('*.mp3') ->in('.');
As described in File::Find::Rule, name can be globs or regular expressions.
name => '*.pm', # a simple glob name => qr/.+\.pm$/, # regex name => ['*.mp3', qr/.+\.ogg$/], # array of rules name => @rules,
$monitor->check();
File::Find::Rule, File::Monitor
dryman, <idryman@gmail.com>
Copyright (C) 2011 by dryman
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.
2022-06-13 | perl v5.34.0 |