#!/usr/bin/perl -w use strict; $| = 1; use Getopt::Std; my %opts; getopts( 'p:f:s:h', \%opts ); my $pattern = $opts{p} || "pdf"; my $sleep = $opts{'s'} || 5; my $logfile = shift || "/tmp/a.log"; my $fh = select( STDOUT ); $|=1; select( $fh ); print "watching file '$logfile' for pattern '$pattern'\n"; open(LOGFILE, "<" . $logfile) or die "not readable: '$logfile'$!\n"; seek(LOGFILE, 0, 2); while (1) { while () { print if /$pattern/o; } sleep $sleep; seek(LOGFILE, 0, 1); }