On Aug 1, 11:57 am, [EMAIL PROTECTED] (Mihir Kamdar) wrote:
> > On 8/1/07, Paul Lalli < [EMAIL PROTECTED]> wrote:
> > > 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.
> @Paul:
> my process_file($file) would scan the file and remove duplicate records from
> the file and write the o/p into another
> directory. That part is taken care of.
That is not what I asked. I asked whether or not process_file() will
remove the file from the directory. If it won't, you need the
%already_seen lines to make sure you don't reprocess the same file
again.
Paul Lalli
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/