Line 1 blah blah blah Line 2 blah blah blah ... Line 1000 blah blah blah Line 1001 --start foo-- [lots of stuff I do need to process] Line 2000 --end foo-- #### my $interesting_bit = 0; while(){ if(/--end foo--/){ $interesting_bit = 0; last; ## assuming only one interesting ## bit per file of course } if($interesting_bit == 1){ ## do my processing on the lines } if(/--start foo--/){ $interesting_bit = 1; # we've found the line which says # the next line needs to be processed } }