|Pathologically Eclectic Rubbish Lister
Re: text processingby Limbic~Region (Chancellor)
|on Apr 22, 2014 at 17:23 UTC
There are many ways to do this because one of Perl's mottos is there is more than one way to do it.
The first method is probably the most common and easiest to think of. At the top of the loop, skip lines that you don't want
Another common first step might be to throw away the first N lines
Sometimes it gets more complicated and you need to check a state variable against multiple lines. I won't give you an example of that abstract case but I will show you what some people do:
The above has a micro-optimization which you should avoid unless you need it. Essentially, it avoids paying the penalty of checking to see if we are in the good data against all lines and starts a new loop with only the processing we care about.
The final method I will share is where you extract or eliminate what you don't want.
As you can see, there are many ways to do what you are looking to accomplish. If you don't understand something, please ask.
Cheers - L~R