frogleg has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to do periodic scans for new files in a single directory and process them with a subroutine.
I've written some code, shown below, but it will only process the subroutine once.
I've got two questions for the Monastery:
As always, thanks very much.
#!/usr/bin/perl -w use strict; my $dir = "/home/dhaffner/src/codemonkey/test"; opendir (DIR,$dir) or die "That's all folks!"; { do { my @files = grep { -f "$dir/$_" } readdir(DIR); foreach my $file (@files) { GoProcess ($file); } } while (sleep(30)) } closedir (DIR); sub GoProcess { print "I can process $_[0] for you now.\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help periodically scanning directories to process new files
by merlyn (Sage) on Mar 21, 2001 at 01:48 UTC | |
|
Re: Help periodically scanning directories to process new files
by Hot Pastrami (Monk) on Mar 21, 2001 at 02:04 UTC |