while() { my $source = $_; next if ($source =~ m/^(\s)*$/); next if ($source =~ m/^(\s)*$/); #Go through each line until you hit page 1 of sorter 2 if (substr($source,145,16) =~ /Page: 1/) { next; next; if (substr($source,72,9) =~ /Sorter: 2/) { ++$dcount; printf LOGFILE $source; } } }