Good afternoon dear Monks,
I'm attempting to search logs using tail -f so if the specific string got into the log file we should print the first 3 occurrences and continue the rest of the script, but it is not working. The strings passed as a commandline argument.
I appreciate the your valuable input
use warnings;
use strict;
my $currentDate = `date +%Y%m%d`;
my $logPath = "/dhcp/logs"
my $logFile = "{$path}/DHCPD.log.{$currentDate}"
my @tail = qx(tail -f -1 $logFile | grep $_);
if (@tail) {
print @slice = @tail[0 - 2];
last;
}
else {
print "not found";
}