in reply to Re: Log watcher which outputs alerts in xterm windows
in thread Log watcher which outputs alerts in xterm windows

Thanks for your advice about swatch, I'm going to give that a try, but I'm still going to try and make this program work to try and improve my perl skills. I just had an idea of rather than comparing two files, I could compare two arrays. Since the program is going to check every x amount of minutes, I could store one of the arrays as an old array and then 5 minutes later when it checks, I could slurp the burst of messages in a new array, those two arrays could then be compared and any different lines, could be written to a file and then outputted to an xterm window using the less command. I don't really know how to do it though. Does it seem possible?
  • Comment on Re^2: Log watcher which outputs alerts in xterm windows

Replies are listed 'Best First'.
Re^3: Log watcher which outputs alerts in xterm windows
by moritz (Cardinal) on Jun 23, 2008 at 09:14 UTC
      I think I will give that module a try thanks. I did try changing the subroutine for reading the messages file to the following, but it doesn't find any differences, does anybody know why? Is there a problem in the logic?
      sub msg_got_record { my $log_record = $_[ARG0]; print " $log_record\n"; push (@array_curr, "$log_record\n"); if (@array_prev){ %array_curr = map {$_, 1} @array_curr; @difference = grep {!$array_curr {$_}} @array_prev; print "this is a difference @difference\n" } else {print OUTPUT "@array_curr"; print "this is else - debug @arr +ay_curr";} @array_prev = @array_curr;