If it's always 8 lines after the start line, then go ahead and read a record of 8 lines when you detect start, and then process them as a group:
if ($line1 =~ m/^Start/) { # Append the rest of the record $line1 .= <LOGFILE> for 1..7; }
If you care only about the first and last lines, though, you could just skip the intervening lines:
if ($line1 =~ m/^Start/) { # Skip to the end of the record my $t = <LOGFILE> for 1..6; my $lastline = <LOGFILE>; }
However, if you simply chomp your input line for the start record, you'll get the single line you want. Note: Some people (myself included) find it more convenient to remove all whitespace from the end of lines using $line =~ s/\s+$//; or equivalent.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re: Simple Parsing Script
by roboticus
in thread Simple Parsing Script
by swilhelm73
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |