in reply to parse from last occurence of pattern match
I'd be inclined to store the file offset of either the line or the line following the last match (using tell) then you can seek to the position in the file that you want to continue from having reached the end of the file.
The following code demonstrates the technique:
use strict; use warnings; my $lastFound = -1; # No match value $| = 1; /\ba\b/ and ($lastFound = tell DATA) while <DATA>; print "No match \n" and exit if $lastFound == -1; seek DATA, $lastFound, 0; print <DATA>; __DATA__ Hi, I've seen a few similar problems to this posted here recently but +none of them cover what I need to do and my Perl isn't strong enough yet for m +e to figure out how to do this. I'm parsing a number of text files (can ran +ge in size from 1K upto 100M) where the record size of each line is variable. I n +eed to find (or seek to ?) the last occurence of a pattern then apply some fu +rther parsing logic from that point on until the end of file. What I do now +(which doesn't cope with the problem) is:
Prints:
parsing logic from that point on until the end of file. What I do now +(which doesn't cope with the problem) is:
|
|---|