Hi All,
I am trying a simple program in PERL, but unable to get it working
$log="test.log";
open(LOGFILE, $log) or die("Could not open log file.");
foreach $line (<LOGFILE>) {
chomp($line);
if($line eq "Raghu") {
print "Found a group\n";
$var=<LOGFILE>;
chomp($var);
print "$var\n";
}
}
Whenever the line contains the letters "Raghu", I am trying to read the next line into the var variable. But nothing is getting printed as output except the statement "Found a group".
What is wrong in the code?
Thanks a lot for the time.
The test.log is as follows
Raghu
Hai