|
|
| Don't ask to ask, just ask | |
| PerlMonks |
Re: raw data formattingby roboticus (Canon) |
| on Nov 16, 2012 at 00:24 UTC ( #1004086=note: print w/ replies, xml ) | Need Help?? |
|
Part of the difficulty appears to be that the file may have some lines you want to discard. Since the $. variable keeps track of the lines read and not the lines wanted, using the modulo operator on it is going to fail. However, the modulo operator idea is a *good* one, you just need to keep track of the lines you want to keep yourself:
Another way you could do it is to simply accumulate the lines you want, and when you have five, process the lot of 'em:
It may be coincidence, but it seems like the first record of each group always has a 'Z' (?record type indicator?) around column 20. If it's not a coincidence, then another way to handle it would be to accumulate records until you find a line with a 'Z' marker, then process all the records you have, and then put the new record into the accumulator. Update: Fixed a code tag. ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||