in reply to Finding a line after a keyword
My brain needed something brainless to do. So I checked to see if I could translate the unformatted mess in the OP into something I could read and chew on. (Don't count on this ever happening again; see, instead Markup in the Monastery.
The exercise was not terribly productive, as the raw translation (minus my errors in fixup) yielded so many errors that perl -c D:\PMonks\1126473.pl balked at further checking. But the good news was that most of what the check turned up with accounted for by my use of strict and thus were fairly easy to identify. However, what appears as Ln3 below was missing an Open_Paren:
while ($line = <F>) { if ($. == $findline) { ($field1, $field2, $field3, $field4) = split ' +,', $line;
That, alone, is a no-no here. When you post code, cut'n'paste from something that compiles; don't retype (and if that's what you did here, that may be the cause of the missing paren) because retyping invites typos.
That said, there's another deficiency in your code: you tell us that you're now keying off the word "MILLISEC" but you don't specify whether that's -- well, somewhere in the variable headers -- or somewhere in the data AND a reliable number of lines before the data you're trying to extract.
If that latter, of course, roboticus' response, above, is pretty much all you need (assuming you have actual working code. If the former, what's the relationship between the appearance of "MILLISEC" and the location of the data you want? Obviously, we need to know that to help, and the lack of that information points to another possible weakness in your question -- the lack of sample data.
So, this is only a WAG: if "MILLISEC" has a consistent relationship (in lines of separation) to your data, you need only do exactly as advised above; if the relationship is NOT one of lines of separation then your first step has to be finding a quantifiable relationship or finding a different key that is a reliable indicator.
|
|---|