in reply to processing logic help
You might need to initialize sentinel.txt to sync it up to the first file. Just put "1234" (no newline) into the file, where you expect elmo1234.txt to be the next rsync'ed file.use File::CounterFile; my $counter = File::CounterFile->new("/path/to/sentinel.txt", "0000"); chdir "/path/to/where/the/files/are" or die "chdir: $!"; ## see if a new file has arrived while (-e (my $file = "elmo$counter.txt")) { process_file($file); $counter = "0000" if ++$counter == "10000"; }
update: (to add some explanation...)
The File::Counterfile module creates a persistent file. The object returned from the module is overloaded so that it can be incremented and interpolated, but every change to the object gets reflected as a change to the original file. It uses Perl's "magical autoincrement" to generate items here from 0000 to 9999. Of course, when that wraps, I need to force it back to 0000. I'm also presuming this program gets invoked every 15 minutes or whatever, and that process_file unlinks the file as it does the job.
And now the explanation is longer than the program, so I'll stop. {grin}
-- Randal L. Schwartz, Perl hacker
|
|---|