Name : perl-File-Monitor
| |
Version : 1.00
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : 255.50
| Date : 2024-08-05 18:40:49
|
Group : Development/Libraries/Perl
| Source RPM : perl-File-Monitor-1.00-255.50.src.rpm
|
Size : 0.07 MB
| |
Packager : (none)
| |
Summary : Monitor files and directories for changes
|
Description :
This module provides a simple interface for monitoring one or more files or directories and reporting any changes that are made to them.
It can
* * monitor existing files for changes to any of the attributes returned by the \'stat\' function
* * monitor files that don\'t yet exist and notify you if they are created
* * notify when a monitored file is deleted
* * notify when files are added or removed from a directory
Some possible applications include
* * monitoring the configuration file(s) of a long running process so they can be automatically re-read if they change
* * implementing a \'drop box\' directory that receives files to be processed in some way
* * automatically rebuilding a cached object that depends on a number of files if any of those files changes
In order to monitor a single file create a new monitor object:
my $monitor = File::Monitor->new();
Add the file to it:
$monitor->watch( \'somefile.txt\' );
And then call \'scan\' periodically to check for changes:
my AATTchanges = $monitor->scan;
The first call to \'scan\' will never report any changes; it captures a snapshot of the state of all monitored files and directories so that subsequent calls to \'scan\' can report any changes.
Note that \'File::Monitor\' doesn\'t provide asynchronous notifications of file changes; you have to call \'scan\' to learn if there have been any changes.
To monitor multiple files call \'watch\' for each of them:
for my $file ( AATTfiles ) { $monitor->watch( $file ); }
If there have been any changes \'scan\' will return a list of File::Monitor::Delta objects.
my AATTchanges = $monitor->scan; for my $change (AATTchanges) { warn $change->name, \" has changed\ \"; }
Consult the documentation for File::Monitor::Delta for more information.
If you prefer you may register callbacks to be triggered when changes occur.
$monitor->callback( sub { my ($file_name, $event, $change) = AATT_; warn \"$file_name has changed\ \"; } );
$monitor->callback( size => sub { my ($file_name, $event, $change) = AATT_; warn \"$file_name has changed size\ \"; } );
See File::Monitor::Delta for more information about the various event types for which callbacks may be registered.
You may register callbacks for a specific file or directory.
$monitor->watch( \'server.conf\', sub { my ($file_name, $event, $change) = AATT_; warn \"Config file $file_name has changed\ \"; } );
$monitor->watch( { name => \'server.conf\', callback => { uid => sub { my ($file_name, $event, $change) = AATT_; warn \"$file_name has changed owner\ \"; } } } );
This last example shows the canonical way of specifying the arguments to \'watch\' as a hash reference. See \'watch\' for more details.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-F/openSUSE_Tumbleweed/noarch |