Akihito Takeda > File-Stat-Trigger-0.05 > File::Stat::Trigger

Download:
File-Stat-Trigger-0.05.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.05   Source  

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->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);

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. Set file parameter.

atime_trigger

Register atime trigger. Set file parameter.

ctime_trigger

Register ctime trigger. Set file parameter.

mtime_trigger

Register mtime trigger. Set file parameter.

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.

syntax highlighting: