I run through the file using an until loop, at the end of each pass I
write the last position in the file (using tell()), and the next
timestamp to start from, to a text file called gather.dat.  This lets it
pick back up where is started using seek() first, saves a lot of time,
and as long as nothing changes the beginning of the file it moves along
just fine. 

I like Terry's method for a memery resident scan, may toy with it, mine
has to be run every 5 minutes or so, of course you can also write a
memory resident perl script that calls the other two on a schedule and
run it from something like Firedaemon. As Terry said, there is always
more than one way, pick the one that suits you best.

Thanks,
Chuck Frolick
ArgoNet, Inc.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of Smart Business
Lists
Sent: Friday, February 07, 2003 7:24 PM
To: Duane Cox
Subject: Re: [Declude.JunkMail] New Util


Duane,

Friday, February 7, 2003 you wrote:
DC> I have a question, how do you get perl to rescan the same log it
scanned 5
DC> minutes before, and pick up where it left off?

Always more than one way - but here is one possibility:

sub tail_log {
  my $iteration = 0;
  for (;;) {
    while (<LOGFILE>) {
      next unless length;
      # do some stuff
      sleep $nap;
      # dont' forget to check the date to see if we have gone to next
day
      # and if so you have to close and then open new log at end and
      # so on
      seek(LOGFILE, 0, 1);
    }
  }
}

hth

Terry Fritts

---
[This E-mail was scanned for viruses by Declude Virus
(http://www.declude.com)]

---
This E-mail came from the Declude.JunkMail mailing list.  To
unsubscribe, just send an E-mail to [EMAIL PROTECTED], and
type "unsubscribe Declude.JunkMail".  The archives can be found
at http://www.mail-archive.com.

---
[This E-mail was scanned for viruses by Declude Virus (http://www.declude.com)]

---
This E-mail came from the Declude.JunkMail mailing list.  To
unsubscribe, just send an E-mail to [EMAIL PROTECTED], and
type "unsubscribe Declude.JunkMail".  The archives can be found
at http://www.mail-archive.com.

Reply via email to