tail -f doesn't end until you interrupt it. Try something like this:
#! perl -slw use strict; my $pid = open TAIL, '-|', 'tail -f theLog' or die $!; my @matches; while( @matched <3 and defined( $_ = <TAIL> ) ) { push @matches, $_ if /the search term/; } kill 2, $pid; ## do something with the 3 lines in @matches.
In reply to Re^3: Watch log for string (tail -f)
by BrowserUk
in thread Watch log for string (tail -f)
by hmb104
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |