my $in_combat = 0; #open the file for input LINE: while (my $line=readline($input_file)) { if (# line contains start-combat flag) { $in_combat = 1; } next LINE if (!$in_combat); # do stuff with lines *during* combat--beginning and end will be here, too! if (#line contains end-combat flag) { $in_combat = 0; } } # close files, etcetc