in reply to
Re^2: searching across a file then parsing
in thread searching across a file then parsing
This is purely a guess, but I suspect that rather than a character-by-character numerical position change (like that provided by 'seek'), the OP is looking for a "line-by-line cache" - similar to something I did recently.
I'm going to assume that the file is too big to stuff into a scalar and process with something like /($start.*?$match.*?$end)/ - i.e., that it does indeed need to be read one line at a time.
my $pat1 = "TOP_PATTERN";
my $pat2 = "SEARCH_PATTERN";
my ($flag, $cache);
last if /$pat1/;
print and next;
$cache = "" and next if $cache;
$cache .= $_ and next;
$cache .= $_;
$flag = 1 and print $cache if /$pat2/;
I hate storms, but calms undermine my spirits.
-- Bernard Moitessier, "The Long Way"