#!/usr/bin/perl # Slednet # Nov 22 2002 # reads the last 200 characters of a file then sleep for 10 second intervals periodically checking for new data. use Getopt::Long; # get the file name my $ret = GetOptions ("f|filename:s"); my $filename = $opt_f || die "Usage: $0 -f filename\n"; # open file open (INPUT, "$filename") || die "Can't open file $filename : $!\n"; # move to the last 200 characters in the file seek(INPUT, -200, 2); # loop forever testing the file for(;;) { #read the 200 characters for($curpos = tell(INPUT);$_=;$curpos = tell(INPUT)) { #print info when we get it print "$_"; } #sleep for 10 seconds sleep 10; #move cursor to end of file seek(INPUT, $curpos, 0); }