in reply to Help periodically scanning directories to process new files
...but I'm not sure if time() will return the new time, or keep returning the time when the script was first executed. I'll try to find out, and post more in a little while.#!/usr/bin/perl -w use strict; my @files = (); my $dir = "/home/dhaffner/src/codemonkey/test"; my $lastUpdate = 0; LOOP: { opendir(DIR, $dir) or die "Died: $!"; @files = grep { -f "$dir/$_" && (stat "$dir/$_")[9] > $lastUpdate +} readdir(DIR); closedir(DIR); GoProcess("$dir/$_") foreach @files; $lastUpdate = time; sleep 30; redo LOOP; }
|
|---|