I've got a log file I am trying to parse with Perl. Basically I want to select two lines and then concatenate to print out both values on one line.
What I have so far;
#!/usr/bin/perl -w
#use strict;
my $line1=$_;
$LOGFILE="Output.txt";
open(LOGFILE) or die("Could not open Output.txt.");
foreach $line1(<LOGFILE>) {
if ($line1 =~ m/^Start/)
{
$time = $line1;
}
elsif ($line1 =~ m/^Response\s+Time\s+\(avg\):\s+([0-9.]+)/)
{
$response = $line1;
}
{print join $time $response}
}
The problem is that I am grabbing each line separately so my result is of the format:
Start: Blah
Response Time Blah
when I want
Start: Blah Response Time Blah
The Response Time line is always 8 lines below the Start line, so I think I could set both variables at the same time if I knew how to tell Perl to search 8 lines below the match.
Thanks for any help!
Bookmarks