File::Stat::Trigger - The module to monitor the status of file.
use File::Stat::Trigger; my $file = 'sample.txt'; my $fs = File::Stat::Trigger->new({ file => $file, check_atime => ['>=','2008/12/1 12:00:00'], check_ctime => ['>='], check_mtime => ['==', '2008/12/1 12:00:00'], check_size => ['!=',1024], auto_stat => 1, }); $fs->size_trigger( sub { my $self = shift; my $i = $self->file_stat->size; } ); $fs->atime_trigger(\&sample); $fs->ctime_trigger(\&sample); # $fs->ctime_trigger(\&sample,['!=', '2008/12/1 12:00:00']); $fs->mtime_trigger(\&sample); # $fs->mtime_trigger(\&sample,['!=', '2008/12/1 12:00:00']); my $result = $fs->scan(); $result->{size_trigger};# 1 $result->{atime_trigger};# 1 $result->{ctime_trigger};# 0 $result->{mtime_trigger};# 0 # This function execute 'scan()' in three interval. $result = $fs->run(3);
This module executes the registered function when the stat of file changed and matched parameter.
Set file name, file parameter.
Register size trigger. Set file parameter.
Register atime trigger. Set file parameter.
Register ctime trigger. Set file parameter.
Register mtime trigger. Set file parameter.
Scan file stat.
This function execute 'scan()' in any interval.
Akihito Takeda <takeda.akihito@gmail.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install File::Stat::Trigger, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::Stat::Trigger
CPAN shell
perl -MCPAN -e shell install File::Stat::Trigger
For more information on module installation, please visit the detailed CPAN module installation guide.