[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Opening dynamic text file



On Sat, Sep 18, 1999 at 11:01:20AM +1000, Mark M wrote:
> Apols for the non debian specific Q, but I was hoping someone would
> know how I could read in and process a file (a log file in this case),
> and then when further lines are written read these without reloading
> the whole file (performance considerations).

  Maybe you want to open the file as a pipe from tail -f. Something
  like:

  open LOG, "tail -f </var/log/syslog |" or
  	die "Couldn't open log file";
  
  Then maybe you work up a couple loops that check the input stream.

  for (;;) {
  	while (<LOG>) {
		$quit = myprocess $_; # process the line...
	}
	last if $quit;
	sleep 5; # or some length of time
  }

  You might check the tail man page for other options that could be
  useful. 
-- 
+---+----+-----+---+----+-----+---+----+-----+
|   YOUR AD HERE............1.900.FOO.BARZ   |
+-----+---+----+-----+---+----+-----+---+----+


Reply to: