On Aug 1, 11:14 am, [EMAIL PROTECTED] (Mihir Kamdar) wrote:
> It has to be ASAP Shawn......but if that's not possible, as a workaround we
> may also look at every half hour or something like that...

So enter an infinite loop in which you process the directory, sleep
one second, process the directory, sleep, etc.

> do you have any suggestions in mind?
> I am also unaware how to scan the directory for each of the files....like in
> shell i can do something like
> for i in 'ls -lrt *.*"

perldoc -f opendir
perldoc -f readdir.

I'm really not understanding what the problem is.  If you would show
us your best attempt, we could show you where you're going wrong.

Here's a very brief example.

my %already_seen;
while (1) {
   opendir my $dh, '.' or die "Could not open this directory: $!";
   while (my $file = readdir($dh)) {
       next if $file =~ /^\.\.?$/;
       next if $already_seen{$file}++;
       process_file($file);
   }
   sleep(1);
}

The definition of process_file is, of course, up to you.   If part of
processing the file involves removing the file from the directory, you
can eliminate the `my %already_seen;` and `next if $already_seen{$file}
++;` lines.

If this isn't what you're looking for, you need to specify your
requirements better, not to mention your best attempt at solving your
problem.

Paul Lalli


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to