NAME
File::Stat::Trigger - The module to monitor the status of file.
SYNOPSIS
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->mtime_trigger(\&sample);
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);
DESCRIPTION
This module executes the registered function when the stat of file changed and matched parameter.
METHODS
- new({file=>'filename'...})
-
Set file name, file parameter.
- size_trigger
-
Register size trigger.
- atime_trigger
-
Register atime trigger.
- ctime_trigger
-
Register ctime trigger.
- mtime_trigger
-
Register mtime trigger.
- scan
-
Scan file stat.
- run(second)
-
This function execute 'scan()' in any interval.
AUTHOR
Akihito Takeda <takeda.akihito@gmail.com>
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.