ETLp::File::Watch - Waits for the appearance of a specific file or one or more files that match the supplied patterns
A watcher will look for the existence of a file matching the supplied pattern (glob not regex) and then exits. Generally it signals that processing is required by the next item in the pipeline (which will generally want to use the file that matches that pattern).
Generally, detection of a file matching the pattern shouldn't be sufficient grounds for a watcher to exit. It should poll the file size at intervals to determine whether it is still growing. A watcher should only exit when the file size stops changing.
use ETLp::File::Watch; my $watcher = ETLp::File::Watch->new( directory => "$Bin/../incoming", file_pattern => 'data*.zip', duration => '5h' ); unless ($watcher->watch() { die "file not detected"; }
Creates a new watcher
A hashref containing:
* directory. Optional string. The location of the watch file * file_pattern: Required string. The pattern (glob) that the watcher is waiting for * call: Required string. The config file and section to invoke when a file is successfully found * duration. Required. How long the watcher should wait before giving up. The time can be specified by the duration (integer) followed by s, m, h or d - (seconds, minutes, hours or days) * wait_time. Optional integer. The time in seconds between each iteration of the check. Defaults to 1 * raise_no_file_error. Optional boolean. If set to 1, an error will be raised if the watcher expires without encountering a file. Deafults to 0. * exit_on_detection. Optional boolean. If set to 1
* A file watcher
Watches for the existence of a file pattern
* None
* Void
To install ETLp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ETLp
CPAN shell
perl -MCPAN -e shell install ETLp
For more information on module installation, please visit the detailed CPAN module installation guide.