open file for reading; $found_dtd = 0; while not end of file { next unless string has pattern known to be after DTD or schema if line matches DTD or schema regex { $found_dtd = 1; last; } } return $found_dtd;