in reply to Help With Parsing a File

You could maintain a small shift buffer with the last two lines read, which would work even when the data file is large.
use strict; my $value = 0; my @linebuf; open IN, "data.file" or die "$!"; for (0..1) { $_ = <IN>; push @linebuf,$_; } while (<IN>) { if (/^--/ and $linebuf[0] =~ /ABC SET/) { print "Matched ",$linebuf[0]; $value++; } shift @linebuf; push @linebuf,$_; } close IN or warn "$!"; print "total found is $value\n";