As of:  Mon 2014-09-01 13:40:02 UTC  [=1409578802. 09:40:02-04:00]

>> titles.pl  L: 70,306. A: 100644. M: 2010-01-29 22:10:04 UTC [=1264803004] -1675.64d >> 

$version = "2009-12-24, v74.14";
$versionLen = 14 + length($version);

$doVerifyTableTags = 0;
$vt0 = 1;
$maxSum = 0;

$linenr = 1;
@wheres = (
     "c:\\bradstuff\\cloud9", "Dell530", 1,
   # "c:\\bradmcc\\cloud9", "Dell2400", 1,
     "c:\\bradstuff\\cloud9", "Dell1405", 1,
   # "c:\\bradstuff\\cloud9", "mudskipper", 1,
     "c:\\bradstuff\\cloud9", "DellE6400", 1,
     "c:\\bradstuff\\cloud9", "HP", 1,
);
for ($i = 0; ; $i += 3) {
   if ($i >= @wheres) {
      print("titles.pl. Where am I? \"${version}\"\n");
      exit(16);
   }
   if (!(-f $wheres[$i]."\\".$wheres[$i + 1])) {
      next;
   }
   if (open(WHERE, "< " . $wheres[$i] . "\\titles.pl") && $versionLen == read(WHERE, $in, $versionLen) &&
            $in eq "\$version = \"$version\";") {

      $basedir = $wheres[$i];
      $system = $wheres[$i + 1];
      $auditFN = "ai." . $system;
      close (WHERE);
      $doVerifyTableTags = $wheres[$i + 2];
      last;
   }
}

%nodups = ();

$logfile = "titles.log";
if (!open(LOG, "> ${basedir}\\$logfile")) {
   print "Open failed for log file: ${basedir}\\$logfile" . "\n";
   exit(16);
}

%imagesToIgnore = (
  "mwcos.gif", 1,
  "sq/4x4_dn.gif", 1,
  "sq/cycle2.gif", 1,
  "sq/acins10z.gif", 1,
  "gif/signpost-R.gif", 1,
  "gif/black.gif", 1,
  "gif/cat09.gif", 1,
  "gif/kujo.gif", 1,
  "gif/red_right.gif", 1,
  "gif/Albers_mini.gif", 1,
  "gif/cat-kanjiCenter.gif", 1,
  "gif/slowMoving_baggage.gif", 1,
  "gif/voteLilac.gif", 1,
  "gif/blackCat.gif", 1,
  "gif/docimgExt_small.gif", 1,
  "gif/return_character-aqua.gif", 1,
  "gif/rchr-lg.gif", 1,
  "gif/earth.gif", 1,
  "GO/palladio_icon.gif", 1,
  "GO/IHS.gif", 1,
  "GO/catIcon.gif", 1,
  "gif/emilyd.gif", 1,
  "gif/emilydhome.gif", 1,
  "GO/snail_D3.gif", 1,
  "GO/snail.gif", 1,
  "GO/snail_32.gif", 1,
  "GO/snail_whiteBG.gif", 1,
  "GO/japanFlag.jpg", 1,
  "GO/britishFlag.jpg", 1,
  "GO/waterMeter.jpg", 1,
  "GO/plane.jpg", 1,
  "GO/AOLmanB3.gif", 1,
  "GO/ImLovinIt.gif", 1,
  "gif/white4x117.gif", 2,
  "gif/white240x4.gif", 2,
  "GO/6x110white.gif", 2,
  "GO/141x4white.gif", 2,
  "gif/black5x50.gif", 2,
  "sq/black276x1.gif", 2,
  "gif/black60x5.gif", 2,
  "gif/green32x1.gif", 2,
  "GO/white_12x138.gif", 2,
  "GO/white_602x9.gif", 2,
  "GO/white_6x138.gif", 2,
  "GO/1x369red.gif", 2,
  "GO/263x1red.gif", 2,
  "GO/1x158red.gif", 2,
  "GO/602x1red.gif", 2,
  "gif/bv.gif", 2,
  "gif/sp1.gif", 2,
  "n2x2.gif", 2,
  "n2x18.gif", 2,
  "n18x2.gif", 2,
  "sp.gif", 2,
  "lcp/sp.gif", 2,
  "sq/dn.gif", 1,
  "sq/2dn.gif", 1,
  "sq/3dn.gif", 1,
  "sq/4dn.gif", 1,
  "sq/5dn.gif", 1,
  "sq/pbjs.gif", 2,
  "sq/pbjs_white.gif", 1,
  "sq/white36x14.gif", 1,
  "sq/cyberia0.gif", 1,
  "gif/valid-html32new.gif", 1,
  "gif/valid_html3_2b.gif", 1,
  "gif/valid_html4_0-b2a.gif", 1,
  "gif/vcss-new.gif", 1,
  "valid_html4_0.gif", 1,
  "gif/vote39x39.gif", 1,
  "GO/black1x25.gif", 2,
);

if (!open(IN, "< ${basedir}\\iconGallery.html")) {
   print "Open input ${basedir}\\iconGallery.html failed\n";
   exit(16);
}
read (IN, $iconGallery, 60000);
close(IN);
$iconGallery =~ s/<img src="([^"]+)"/($imagesToIgnore{$1} > 0 ? "" : (($imagesToIgnore{$1} = 1),"*"))/geis;

@audit = ();
%filesused = ();
@files = ();
@incFiles = ();
@incFilesF = ();
$sct = 0;
$sumline = "";
$vCount = 0;
%colors = ();
$fpat = ""; # analyze hpctr.pl Regex's
%htmlfiles = ();
getfilenames("");

@months = ("January", "February", "March", "April", "May", "June", "July",
         "August", "September", "October", "November", "December");

@t=localtime($starttime = time());

$now = sprintf("%s-%02d-%02d at: %02d:%02d:%02d %s",
            $t[5]+1900,$t[4]+1,$t[3],$t[2],$t[1],$t[0],($t[8]==0?"EST":"EDT"));
$today = sprintf("%02d %s %s", $t[3], $months[$t[4]], $t[5]+1900);
print "  $version. \"$system\"  >> $now\n\n";

# Extract text for RegEx string from hpctr.pl and update catm.pl (if needed)

if (!open(IN, "< ${basedir}\\cgi-bin\\hpctr.pl")) {
   print "cgi-bin\\hpctr.pl no open.\n";
   exit (0);
}

read (IN, $in, 20000);
close(IN);

if ($in !~ /\#\[(\d\d[A-Z][a-z][a-z]\d\d\&nbsp\;v\d\d+\.\d\d)\]/s) {
   print "cgi-bin\\hpctr.pl no match-1.\n";
   exit (0);
}
$hpts = $1;
 
if ($in !~ / \$who \!\~ \/([^\/]+)\/\) \{\#/s) {
   print "cgi-bin\\hpctr.pl no match-2.\n";
   exit (0);
}
$pattern = $1;
if ($pattern !~ /^\(crawl\|\^\(alb/) {
   print "cgi-bin\\hpctr.pl no match-3.\n";
   exit (0);
}
if ($in !~ /if \(\$uagt \!\~ \/([^\/]+)\/ \&\&/s) {
   print "cgi-bin\\hpctr.pl no match-4.\n";
   exit (0);
}
$patternU = $1;
$hpRegXlen = length($pattern);
$hpRegX2len = length($patternU);

if (!open(IN, "< ${basedir}\\cgi-bin\\catm.pl")) {
   print "cgi-bin\\catm.pl no open.\n";
   exit (0);
}

read (IN, $in, 80000);
close(IN);

$inx = $in;

if ($inx !~ s/\/\(crawl\|\^\([^\/]+\/\) \{\#/\/${pattern}\/) {\#/s) {
   print "cgi-bin\\catm.pl no substitution-1.\n";
   exit (0);
}
if ($inx !~ s/\<\!\-\- hv \-\-\>.*?<\!\-\- \/hv \-\-\>/<!-- hv -->[ hpctr.pl: <font color=purple>${hpts}<\/font> ~ ${hpRegXlen}(+${hpRegX2len}<!-- \/hv -->/s) {
   print "cgi-bin\\catm.pl no substitution-2.\n";
   exit (0);
}

if ($inx ne $in || $ARGV[0] eq "parse") {
   $fpat = "\n" . &parseRegex($patternU) . "\n\n" . &parseRegex($pattern) . "\n";
   print " $linenr. +--> cgi-bin\\catm.pl regX's parsed...\n";
   ++$linenr;
}
if ($inx ne $in) {
   if (!open(OUT, "> ${basedir}\\cgi-bin\\catm.pl")) {
      print "cgi-bin\\catm.pl no open output.\n";
      exit (0);
   }
 
   print OUT $inx;
   close (OUT);
   print " $linenr. +--> cgi-bin\\catm.pl updated!\n";
   ++$linenr;
}

%fn = ();
%fnColor = ();
%doctypes = ();
$f_count = 0;
$notInAvg = 0;
$d_count = 0;
$v_count = 0;
$v40_count = 0;
$v40s_count = 0;
$t_count = 0;
$sigma_chars = 0;
$unprocessed = 0;
$subsubdirhtml = 0;
$i_links = 0;
$ignoredLinks = 0;
$ignored_Xlinks = 0;
$ia_links = 0;           # absolute links to this web site
$i_images = 0;
$iconImages = 0;
$spacerImages = 0;
$dropCapImages = 0;
$countedFiles = 0;
$x_links = 0;
$x_images = 0;
$x_forms = 0;
$applets = 0;
$content_type_yes = 0;
$content_type_no = 0;
$bodyNo = 0;
$bodyOther = 0;
$bodySilver = 0;
$bodyLgrey = 0;

%iphotos = ();
%ilinks = ();
%inames = ();
%xlinks = ();
$vuMax = $vuMax5 = -1;
$checkchars = "";

# Deal with cgi-bin/vuImage.pl indirect hyperlinks
$vuLinks = 0;
$vuLinksI = $vuLinksX = $vuLinksR = 0;
@vusFiles = ("e", "2", "3", "4", "5");
foreach $vuIx (@vusFiles) {
   $vuFile = "cgi-bin\\vuImag${vuIx}.pl";
   if (!open(VU,"< ${basedir}\\$vuFile")) {
      print "Open failed for ${basedir}\\$vuFile\n";
      exit 16;
   }
   $nodups{$vuFile} = 1;
   @stats = stat(VU);
   $diskSize = $stats[7];
   read VU, $vu, 50000;
   close(VU);
   $sum = &chkSum($vu);
   chkLineEnds($vu, $diskSize, $vuFile);
   if ($vu !~ /(v\d\d+\.\d\d)/s) {
      print "Could not find ver stamp in ${basedir}\\$vuFile\n";
      exit 16;
   } 
   $sumline .= "${sum},${1}. ";
   if ($vuIx eq "5") {
      $sumline .= "\n";
   }
   $vu =~ /#Begin array(.*?)#End array\((\d+)\)/s;
   $vu = $1;
   if ($vuIx eq "5") {
      $vuMax5 = $2;
   } else {
      $vuMax = $2;
   }
   while ($vu =~ s/\[ "([^"]+)", *"([^"]+)"(.+?)$//m) {
      @data = ($1, $2);
      $uu = 2;
      $uuText = $3;
      while ($uuText =~ s/<a href\=\\"([^\\]+)\\">//) {
         if (substr($1,0,3) eq "../") {
            $data[$uu++] = substr($1, 3);
            $vuLinksI++;
         } else {
            $vuLinksX++;
         }
      }
      while ($uuText =~ s/<img src\=\\"([^\\]+)\\"//) {
         if (substr($1,0,3) eq "../") {
            $data[$uu++] = substr($1, 3);
            $vuLinksI++;
         } else {
            print " $linenr. $vuFile unknown image: \"$1\"\n";
            ++$linenr;
         }
      }
      for ($i = 0; $i < $uu; ++$i) {
         $url = $data[$i];
         $url =~ /^([^#]+)/;
         $urlBase = $1;
         if (defined $filesused{$urlBase}) {
            $filesused{$urlBase} = 1;
         }
         if (!(defined $ilinks{$url})) {
            $ilinks{$url} = 1;
         }
         if ($url =~ /\.(gif|jpg)$/) {
            $iphotos{$url} = 1;
         }
         if ($i < 2) {
            ++$vuLinks;
         }
      }
      if ($uuText =~ /\" *, *\d+, *\d+, *\d+(, +"DP")?],/) {
         ++$vuLinksR;
      }
   }
}

#******** amcx.pl ********

$vuFile = "cgi-bin\\amcx.pl";
$nodups{$vuFile} = 1;
if (!open(VU,"< ${basedir}\\$vuFile")) {
   print "Open failed for ${basedir}\\${vuFile}\n";
   exit 16;
}
@stats = stat(VU);
$diskSize = $stats[7];
read VU, $amcx, 50000;
close(VU);
$sum = &chkSum($amcx);
chkLineEnds($amcx, $diskSize, $vuFile);
if ($amcx !~ /(v\d\d+\.\d\d)/s) {
   print "Could not find ver stamp in ${basedir}\\cgi-bin\\amcx.pl\n";
   exit 16;
}
$sumline .= "${sum},${1}. ";
$amcx =~ /#Begin array(.*?)#End array\((\d+)\)/s;
$amcx = $1;
#$amcxMax = $2;
while ($amcx =~ s/\[ "([^"]+)", \d+, \d+, \d, "(.+?$)//m) {
   @data = ("sq/$1");
   $uu = 1;
   $uuText = $2;
   while ($uuText =~ s/<a href\=\\"([^\\]+)\\">//) {
      if (substr($1,0,3) eq "../") {
         $data[$uu++] = substr($1, 3);
         $vuLinksI++;
      } else {
         $vuLinksX++;
      }
   }
   while ($uuText =~ s/<img src\=\\"([^\\]+)\\"//) {
      if (substr($1,0,3) eq "../") {
         $data[$uu++] = substr($1, 3);
         $vuLinksI++;
      } else {
         print " $linenr. $vuFile unknown image: \"$1\"\n";
         ++$linenr;
      }
   }
   for ($i = 0; $i < $uu; ++$i) {
      $url = $data[$i];
      if (!(defined $ilinks{$url})) {
         $url =~ /^([^#]+)/;
         $urlBase = $1;
         if (defined $filesused{$urlBase}) {
            $filesused{$urlBase} = 1;
         }
         $ilinks{$url} = 1;
      }
      if ($url =~ /\.(gif|jpg)$/) {
         $iphotos{$url} = 1;
      }
      if ($i < 1) {
         ++$vuLinks;
      }
   }
}


#******** non-.HTML files to audit ********

$sf = "${basedir}\\sgml\\books.inc";
$xf = "${basedir}\\booklist.xml";

$slastmod = -M $sf;
$xlastmod = -M $xf;
if ($slastmod < $xlastmod) {  # always update sgml\books.inc
   if (!open(IN, "< $sf")) {
      print "** Open failed for $sf\n";
      exit 16;
   }
   $inX = "";
   $prevAuthor = "";
   while ($in = <IN>) {
      if ($in !~ s/(.*?)\<r\>\<c[^>]*\>([^<]*)(.*)//s) {
         $inX .= $in;
         next;
      }
      $inX .= $1;
      $author = $2;
      if (" $author" eq " ") {
         $author = $prevAuthor;
      } elsif ($author eq "Author") {
         next;
      } else {
         $prevAuthor = $author;
      }
      $inX .= "<r><author>" . $author .$3;
   }
   $in = $inX;
   $inX = "";

   close IN;
   $in =~ s/.*?\<r\>/<r>/s;
   $in =~ s/\<\/table\>/<\/xtable>/s;
   $in =~ s/\<\/c\>\<c[^>]*\>/<\/author><book>/gs;
   $in =~ s/\<\/c\>\<\/r\>/<\/book><\/r>/gs;
#    $in =~ s/ +\n +/ /gs;
   $in =~ s/ \& / \&amp; /gs;
   $in =~ s/\n +/ /gs;
   if (!open(OUT, "> $xf")) {
      print "** Open failed for $xf\n";
      exit 16;
   }
   print OUT<<"EOFEOF";
<?xml version="1.0"?>
<!DOCTYPE xtable [
<!ELEMENT xtable (r+) >
<!ELEMENT r (author,book) >
<!ELEMENT author (#PCDATA) >
<!ELEMENT book (#PCDATA) >
]>
<xtable>
$in
EOFEOF
   close OUT;
   print " $linenr. --> booklist.xml updated.\n";
   ++$linenr;
}

@auditFiles =
   ("titles.pl", "cgi-bin\\vuImages.pl", "cgi-bin\\catm.pl", "cgi-bin\\uctr1.pl", "cgi-bin\\xctr.pl", "cgi-bin\\hpctr.pl", "NL",
   "cgi-bin\\lor_ipsum.pl", "cgi-bin\\voker.pl", "cgi-bin\\ftd.pl", "cgi-bin\\recents.pl", "cgi-bin\\id.pl", "NL",
   "cgi-bin\\tables.pl", "cgi-bin\\shoes.pl", "cgi-bin\\AbiJethra.pl", "cgi-bin\\myctr.pl", "cgi-bin\\ObL.pl", "NL",
   "cgi-bin\\showmc.pl", "cgi-bin\\moonph.pl", "cgi-bin\\moonph-tx.pl", "cgi-bin\\survey.pl", "cgi-bin\\y2k.pl", "NL",
   "cgi-bin\\jst.pl", "cgi-bin\\posJgb.pl", "heuristic.pl", "heuristic.sgm", "sgml\\test1.sgm", "NL",
   "sgml\\test2.sgm", "sgml\\test3.sgm", "booklist.xml", "marquee.java", "clock.java", "clock2.java", "NL",
   "cgi-bin\\updtGKW.pl", "changed.pl", "cgi-bin\\dDuck.pl", "cgi-bin\\ascii.pl", "cbt.sh", "NL",
   "trim.pl", "addSizes.pl", "cgi-bin\\vokerS.pl", "cgi-bin\\today.pl", "cgi-bin\\subsStat.pl", "NL",
   "verHTML.pl","cgi-bin\\vuImag5.pl", "cgi-bin\\postStamp.pl", "NL",    # , "cgi-bin\\vuImag5.pl"
);

$incNr = @incFiles;
@incFilesS = sort @incFiles;
for ($i = 0; $i < $incNr; ++$i) {
   $f = $incFilesS[$i];
   $f =~ s/\//\\/g;
   push @auditFiles, $f;
   if ($i % 5 == 4) {
      push @auditFiles, "NL";
   }
}

$sumline2 = "";
$lastCharNL = 0;

foreach $auditFile (@auditFiles) {
   if ($auditFile eq "NL") {
      $sumline2 .= "\n";
      $lastCharNL = 1;
      next;
   }
   $nodups{$auditFile} = 1;
   $lastCharNL = 0;
   if (!open(A,"< ${basedir}\\$auditFile")) {
      print "** Open failed for $auditFile file\n";
      exit 16;
   }
   @stats = stat(A);
   $diskSize = $stats[7];
   read A, $au, 100000;
   close(A);
   if ($auditFile =~ /\\(.*?)\.inc$/) {
      $incString = $1;
      $au =~ /<title>(.+?)<\/title>/s;
      $selected = $incString eq "books" ? " selected" : "";
      $af = $auditFile;
      $af =~ s/\\\\/\//;
      push @incFilesF, "<option$selected value=\"${incString}\">$incString \&nbsp;[${af}]\n";
   }
   $nrLines = chkLineEnds($au, $diskSize, $auditFile);
   $v = "?";
   if ($auditFile eq "titles.pl") {
      $sumline2 .= "titles.pl: ${version}. " . &chkSum($au) . "(${nrLines})  .MAXSUM.\nvu: ${sumline}\n\n";
   } else {
      if ($au =~ /(v\d+\.\d+)/s) {
         $v = $1;
      }
      $sumline2 .= &chkSum($au) . ",$v. ";
   }
}

@auditFiles = ();
if ($lastCharNL == 0) {
   $sumline2 .= "\n";
}


#******** process HTML files ********

#$BradsmapList = "";
$myentryFile = "";
$myentryFileWasChanged = "";
$fntriggers = 0;
$maxfnpage = 0;
$maxTriggers = 0;
$fontSizeEqFiles = 0;
foreach $file (sort @files) {
   if ($file !~ /\.html$/) {
      ++$unprocessed;
      next;
   }
   $fileWasChanged = "";
   $pageFlags = "";
   $dirPrefixSlash = $dirPrefix = "";
   $filenameNodir = $file;
   $dirPrefixFS = "";
   if ($file =~ /\//) {    # filenames have been changed to UNIX format: a/b/c
      if ($file =~ /\/[^\/]+\//) {
         print LOG "Subsubdir file ignored: $file\n";
         ++$subsubdirhtml;
         next;
      }
      if ($file =~ /^(geocities|archive)\//) {
         print LOG "Subdir ignore file encountered: $file\n";
         next;
      }
      $file =~ s/\//\\/;
      $file =~ /(^[^\\]+)\\(.*)$/;
      $dirPrefix = $1;
      $dirPrefixSlash = "$dirPrefix/";
      $dirPrefixFS = length( $dirPrefix) > 0 ? "$dirPrefix\\" : "";
      $filenameNodir = $2;
   }
   $thisfileName = "$basedir\\$file";
   $fnColor{$file} = "red";
   open(IN, $thisfileName);
   read(IN, $in, 250000);
   @stats = stat(IN);
   $diskSize = $stats[7];
   close(IN);

   $nrLinesInFile = chkLineEnds($in, $diskSize, $file);

   $in0 = $in;
   $in0 =~ s/(\<\!-- \$fsize file="([^"]+)"([kc]) -->)\d+(k|,\d{3})?/sprintf("%s%s",$1,&getSize($basedir. "\\" . $dirPrefixFS . $2,$3))/egs;
   $in0 =~ s/(\<img src="([^"]+)"\s+width=\d+\s+height=\d+\s+alt="\[[^]("]+\(Image size: )\d+(,\d+)?/sprintf("%s%s",$1,&getSize($basedir. "\\" . $dirPrefixFS . $2, "c"))/egs;
   if ($file eq "workspace.html") {
      #<AREA SHAPE="RECT" COORDS="0,0,560,442" HREF="jpg/Workdesk3.jpg" alt="[ Picture of my computer work area, Mar 97 (Image size: <!--#fsize file="jpg/Workdesk3.jpg"--> bytes) ]">
      $in0 =~ s/(\<AREA\s+SHAPE="RECT"\s+COORDS="\d+,\d+,\d+,\d+"\s+HREF="([^"]+)"\s+alt="\[[^]("]+\(Image size: )\d+(,\d+)?/sprintf("%s%s",$1,&getSize($basedir. "\\" . $dirPrefixFS . $2, "c"))/egs;
   }
   if ($in0 eq $in) {
   } elsif (open (OUT, ">" . $thisfileName)) {
      print OUT $in0;
      close (OUT);
      $in = $in0;    #-------------->>>> the changed file is the real file, now!
      $fileWasChanged = "+";
   } else {
      print " $linenr. Text error (20. Could not write fsize: $thisfileName\n";
      ++$linenr;
   }
   if ($file eq "myentry.html") {  # cache myentry.html for further editing...
      $myentryFile = $in;
   } elsif ($file =~ /^footnotes(\d)?\.html$/) {
      $curfnpage = $1;
      if ($curfnpage > $maxfnpage) {
        $maxfnpage = $curfnpage;
      }
      @junk = $in =~ /\>\d+([a-z])?\<img src\=\"gif\/rchr.gif\" height\=13 width\=12 border\=0 alt\=\"\[ Return to footnote trigger\! \]\"/sg;
      $fntriggers += @junk;
      foreach $x (@junk) {
        if (length($x) > 0 && ($xx = 2 + ord($x) - ord("a")) > $maxTriggers) {
          $maxTriggers = $xx;
          $in =~ /\>(\d+)${x}\<img src\=\"gif\/rchr.gif\" height\=13 width\=12 border\=0 alt\=\"\[ Return to footnote trigger\! \]\"/s;
          $mtfnid = $1;
          $mtfnpg = $curfnpage; 
        }          
      }
   }

   $scta = 0;
   ++$f_count;
   $inx = $in;    # $in is the absolute original input
                  # $inx is the file as we want to look at it (with SGML
                  #     comments removed, etc.?)
                  # $iny is working version, which particular validation
                  #     code can clobber

   if ($in =~ /<body ([^>]+)/is) {
      $bt = $1;
      if ($bt =~ /bgcolor="?(silver|lightgrey|#D3D3D3|#C0C0C0)($|["> ])/i) {
         $bgc = $1;
         if ($bgc =~ /^(silver|#C0C0C0)$/i) {
            ++$bodySilver;
         } else {
            ++$bodyLgrey;
         }
      } else {
         if ($bt =~ /background="?([^">\s]+)/i) {
            $bgi = $1;
            if (substr($bgi,0,3) eq "../") {
               $bgi = substr($bgi,3);
            } elsif ($dirPrefix ne "") {
               $bgi = $dirPrefixSlash . $bgi;
            }
            if (!(defined $filesused{$bgi})) {
               print " $linenr. File $file has unknown bg image: $bgi\n";
               ++$linenr;
            } else {
               $filesused{$bgi} = 1;
            }
            $bgi =~ s/\//\\/g;
            $nodups{$bgi} = 1;
         }
         ++$bodyOther;
      }
   } else {
      ++$bodyNo;
   }
   if ($in =~ /<html>\s*<head>.*?<title>([^<>]*?)<\/title>.*?<\/head>/is ||
      $in =~ /<html xmlns="http:\/\/www\.w3\.org\/1999\/xhtml" xml:lang="en" lang="en">\s*<head>.*?<title>([^<>]*?)<\/title>.*?<\/head>/is ||
      $in =~ /<html>\s*<\!\-\-[^-]*\-\->\s*<head>.*?<title>([^<>]*?)<\/title>.*?<\/head>/is) { # for Yuri
      $title = $1;
   } else {
# <title><!--#exec cgi="cgi-bin/uctr3.pl"-->Rare book library (v1.3)</title>
      if ($in !~ /<html>\s*<head>.*?<title><!\-\-\#exec cgi="cgi\-bin\/uctr3\.pl"\-\->.*?<\/title>.*?<\/head>/is) {
         print "File data error #1 (no title), file: $file\n\n";
         exit 16;
      }
      $title = "Rare Book Library";
   }

   if (defined $fn{$title}) {
      print "File data error #2, file: $file\n    (duplicate title: $fn{$title} / $title)\n";
      exit 16;
   }

   if ($in =~ /<head>.*?<META\s+NAME="description"\s+CONTENT="([^"]*)"\/?>.*?<\/head>/is) {
      $description{$title} = " $1";
      if (($dln = length($1)) > 200 && $file !~ /\-1997\.html$/) {
         print " $linenr. Description $dln chars: $file\n";
         ++$linenr;
         $desclen = ":<font color=blue><b>${dln}</b></font>";
      } else {
         $desclen = ":$dln";
      }
      ++$t_count;
   } else {
      $description{$title} = "";
      $desclen = "";
      print " $linenr. Text error (30. No description meta-tag): $file\n";
      ++$linenr;
   }

   if ($in =~ /^(\<\!doctype .*?\>).*?<html(>| xmlns)/is) {
      $hasdoctype = "";
      ++$d_count;
      $doctypes{$1}++;
      $dtxxx = $1;
      $DOCTYPELEVEL = ($dtxxx =~ /3\.2/) ? "3" : "4";

   } else {
      $hasdoctype = "&ETH;";
      print " $linenr. Text error (40. No doctype): $file\n";
      ++$linenr;
   }

   if ($in =~ /<meta http-equiv="Content-Type" content="text\/html; charset=iso-8859-1"\/?>.*?<\/html>/is) {
      $hascontenttype = "";
      ++$content_type_yes;
   } else {
      $hascontentType = "&cent;";
      ++$content_type_no;
      print " $linenr. Text error (50. No content-type meta-tag): $file\n";
      ++$linenr;
   }

   $iny = $inx;

# Check character entities

   while ($iny =~ s/\&\#([12]\d\d\;|[1-9]\d\;)//s) {
   }
   if ($file eq "gbarchive2.html" || $file eq "gbarchive3.html") {
      while ($iny =~ s/\&\#[123]\d\d\d\d\;//s) {
      }
   } elsif ($file eq "gbarchive4.html") {
      $iny =~ s/\&\#8364\;//s;
   } 
   while ($iny =~ s/(\&\#.{0,4})//s) {
      print " $linenr. Nonconforming character entity (58. \"${1}\"): $file\n";
      ++$linenr;
   }

   $iny = $inx;

# get around problem with moonph.pl "split tag" embed problem in myentry.html (27 Feb 00)

   while ($iny =~ s/(<script.*?<\/script>)//s) {
      $x = $1;
# ---- what is this here for? ----
      if ($x !~ /script/s) {
         print LOG "Program error on split tag embed problem";
         exit(16);
      }
      ++$sct;
      ++$scta;
      print LOG ">> $sct. Script $scta in: $file\n\n$x\n<< $sct. End script $scta in $file\n\n";
      $commentText = $x;
      while ($commentText =~ s/document\.write\('\<applet\s+//is) {
         ++$applets;
      }
   }

   while ($iny =~ /<\!\-\-.*?(<\!|\-\->|$)(.*)/s) {
      $iny = $2;
      $gotcha = $1;
      if ($gotcha ne "-->") {
         $after = substr($iny,0,16);
         $after =~ s/\s/ /gs;
         print " $linenr. Text error (60. Bad SGML comment: \"$after\"): $file\n";
         exit(16);
      }
   }
 
   if ($inx =~ /<\!\-\-(?!(\s|#fsize |#config |#exec ))(.{0,48})/is) {
      $after = $2;
      $after =~ s/\s/ /gs;
      print " $linenr. Text error (70. \"<--$after\"): $file\n";
      ++$linenr;
   }
   $iny = $inx;
   $iny =~ s/<\!\-\-#(fsize |config |exec )[^\s]*?\-\->//gis;
   if ($iny =~ /([^\s\/]\-\->|\S\/\/\s*\-\->)(.{0,48})/is) {
      $after = $2;
      $after =~ s/\s/ /gs;
      print " $linenr. Text error (80. \"-->$after\"): $file\n";
      ++$linenr;
   }
#   chkLineEnds($inx, $diskSize, $file);
   $fileNmX = $file;
   $fileNmX =~ s/\\/\//;
   $fileNmX =~ s/\./\\./g;
   if ($inx !~ /http:\/\/www\.(users\.)?cloud9\.net\/\~bradmcc\/$fileNmX/s) {
      print " $linenr. Filename not in file: $file\n";
      ++$linenr;
   }
 
#---- create change tracking entry for file ---- AUDIT!
   if ($file eq "myentry.html" || $file eq "ObjektiveGeist.html" || $file eq "iconGallery.html") {
      $emsg = "";
      if (($file eq "myentry.html" && $inx !~ /^version = ([^;]+);$/m) ||
            (($file ne "myentry.html") && ($inx !~ /\<\!\-\- version -->([^<]+)\<\!\-\- \/version \-\-\>/s))) {
         $emsg = " $linenr. Text error (100. Missing version id): $file\n";
         print $emsg;
         ++$linenr;
         ++$vCount;
         $vcopy = "??";
      } else {
         $vcopy = $1;
      }
      $dataCopy = $inx;
      $deltaSize = length($dataCopy);
      $dataCopy =~ s/\<\!\-\- CDATE \-\-\>.*?<\!\-\- \/CDATE \-\-\>/<!-- CDATE --><!-- \/CDATE -->/s;
      $dataCopy =~ s/\<\!\-\- ([^ ]+) \-\-\>[^<]+\<\!\-\- \/\1 \-\-\>/$1/gs;
      $deltaSize -= ($reducedSize = length ($dataCopy));
      $reducedSum = &chkSum($dataCopy);
      $nrLinesInFile = chkLineEnds($dataCopy, $diskSize - $deltaSize, $file);
      push @audit, "$file -\"$vcopy\"- ${nrLinesInFile}. $reducedSize $reducedSum $emsg";
   } elsif ($file !~ /^titles\d\.html$/) {
      $sum = &chkSum($in);
      $vNr = "";
      $inw = $in;
      $vCt = 0;
      while ($inw =~ /(v\d+\.\d+)(.*)/s) {
         ++$vCt;
         $vNr .= $1;
         $inw = $2;
      }
      if ($vCt != 1) {
         $emsg = " $linenr. Text error (101. Version id count: $vCt != 1): $file. $vNr\n";
         print $emsg;
         ++$linenr;
         ++$vCount;
         $vNr = "${vCt}?-$vNr";
      } elsif ($vNr !~ /^v\d{2}.\d{2}$/ &&
                    !($file eq "heuristic.html" && $vNr eq "v1.31")) {
         $emsg = " $linenr. Text error (102. Version id bad format: \"$vNr\"): $file\n";
         print $emsg;
         ++$linenr;
         ++$vCount;
      }
      push @audit, "$file ${nrLinesInFile}. $diskSize ($sum)  $vNr";
   }

# <!--#exec cgi="cgi-bin/uctr4.pl"-->

   $isCounted = "\&nbsp;";
   if ($inx =~ s/<\!\-\-\#exec cgi\=\"(\.\.\/)?cgi\-bin\/(uctr[0-9ABC]|pm|xctr|lor_ipsum|myctr|hpctr|AbiJethra|shoes|y2k)\.pl\"\-\-\>//s) {
      $isCounted = "\&cent;";
      ++$countedFiles;
   }
   $inx =~ s/<\!\-\-.*?\-\->//gis;                # remove sgml comments and SSIs

   if ($doVerifyTableTags) {
      $incolor = $inx;
      $incr = ($file eq "iconGallery.html") ? 1 : 2;
      $incolor =~ s/(color| link| vlink| alink)(="?|: *)([^\s">;]+)/($colors{$3} |= ${incr})/gies;
   }

   if ($doVerifyTableTags) {
      if ($inx =~ /(<td[^>]*>[^<]*<td)/is) {      #---- try to detect messed up table tagging ----
         print " $linenr. Text error (120. tdtd: $file\n    \"$1\"\n";
         ++$linenr;
      }
      $ink = $inx;
      $ink =~ s/\s//gs;
      $ink =~ s/1/2/gs;
      $ink1 = $ink;
      $ink1 =~ s/\<td/1/gis;
      $ink1 =~ s/[^1]//gs;
      $ink2 = $ink;
      $ink2 =~ s/\<\/td/1/gis;
      $ink2 =~ s/[^1]//gs;
      if (length($ink1) != length($ink2)) {
         print " $linenr. Text error (130. td/td: $file " . length($ink1) . "!=" . length($ink2) . "\n";
         ++$linenr;
      }
      $ink = $inx;
      $ink =~ s/\s//gs;
      $ink =~ s/1/2/gs;
      $ink1 = $ink;
      $ink1 =~ s/\<tr/1/gis;
      $ink1 =~ s/[^1]//gs;
      $ink2 = $ink;
      $ink2 =~ s/\<\/tr/1/gis;
      $ink2 =~ s/[^1]//gs;
      if (length($ink1) != length($ink2)) {
         print " $linenr. Text error (140. tr/tr: $file " . length($ink1) . "!=" . length($ink2) . "\n";
         ++$linenr;
      }
   } elsif ($vt0) {
      print " $linenr. --> Neither counting table tags nor auditing colors!\n";
      ++$linenr;
      $vt0 = 0;
   }

   if ($inx =~ /<img\s+src="[^v"><]*valid_html(\d)_[^">.]+?\.gif"[^>]+?alt="[^>"]*?(Loose|Strict)?\s+HTML[^>"]*?Checked!/is) {
      if ($1 eq "4") {
         if ("$2" eq "Strict") {
            ++$v40s_count;
         }
         ++$v40_count;

         if ($DOCTYPELEVEL ne "4" ) {
            print "---- says 4 but is not: $file\n";
         }

      } else {
         ++$v_count;
         if ($DOCTYPELEVEL ne "3" ) {
            print "---- says 3 but is not: $file\n";
         }

      }
   } elsif ($inx =~ /HTML W3C validated/ || $inx =~ /XHTML 1\.0 Checked/ ||
                                     ($file eq "VRMLworld.html" && $in =~ /HTML W3C validated/)) {
      if ($DOCTYPELEVEL eq "3") {
         ++$v_count;
      } else {
         ++$v40_count;
      }
   } else {
      $pageFlags .= "X";
   }

   if ($inx =~ /<\s(.{0,48})/is) {
      $after = $1;
      $after =~ s/\s/ /gs;
      print " $linenr. Text error (150. \"<\\s$after\"): $file\n";
      ++$linenr;
   }
   if ($inx =~ /\s>(.{0,48})/is) {
      $after = $1;
      $after =~ s/\s/ /gs;
      print " $linenr. Text error (160. \"\\s>$after\"): $file\n";
      ++$linenr;
   }
   if ($inx =~ /<a\s+(?!(\s|href="|name="))(.{0,48})/is) {
      $after = $2;
      $after =~ s/\s/ /gs;
      print " $linenr. Text error (170. \"<a\\s+(?=[^nh\\s])$after\"): $file\n";
      ++$linenr;
   }
   if ($inx =~ /<img\s+(?!(\s|src="))(.{0,48})/is) {
      $after = $2;
      $after =~ s/\s/ /gs;
      print " $linenr. Text error (180. \"<img\\s+(?=[^s\\s])$after\"): $file\n";
      ++$linenr;
   }
   if ($inx =~ /[`\x00-\x09\x0b-\x1f\x7f-\xff](.{0,48})/is) {
      $after = $1;
      $after =~ s/\s/ /gs;
      print " $linenr. Text error (200. \"[`\\t\\x7f-\\xff]$after\"): $file\n";
      ++$linenr;
   }

   $fi_links = 0;                    # relative internal links to this site
   $fi_TemplateLinks = 0;
   $fia_links = 0;                   # absolute internal links to this site
   $fi_images = 0;
   $fx_links = 0;
   $fx_images = 0;
   $fx_forms = 0;
   $iny = $inx;

# get name= designators
   $inz = $iny;
   while ($inz =~ /<a [^>]*?name="([^:>"]+)"[^>]*>(.*)/is) {
      $inz = $2;
      $name = $1;
      $name = $dirPrefixSlash.$filenameNodir."#".$1;
      if (defined $inames{$name}) {
         print " $linenr. Duplicate <a name= label: $name\n";
         ++$linenr;
      } else {
         $inames{$name} = 1;
      }
   }

   %mailTos = ();
   $iny =~ s/<a[^>]+?href="mailto:(bradmcc\@cloud9\.net|louisfors\@aol\.com|laurent\.sabarthez\@mipnet\.fr|bm1\@smarts.com)"\s*>//gis;
                                    # we are not interested in counting mailto-me's
   while ($iny =~ s/<a[^>]+?href="(mailto:[^"]*)"\s*>//is) {
      if (defined $mailTos{$1}) {
         next;
      }
      $mailTos{$1} = 1;
      print " $linenr. $1 found in: $file\n";   # we are interested in find out who else
                                    # we might bemailing to
      ++$linenr;
   }

# count JAVA applets
   $inz = $iny;
   while ($inz =~ s/<applet\s+code="([^">]+)"(\s+archive="([^">]+)")?[^>]*>//is) {
 
      $url = $1;
      if ("$3 " ne " ") {  # Swatchtime.jar
          $url = $3;
      }
      if (defined $filesused{$url}) {
          $filesused{$url} = 1;
      }
      $ilinks{$url} = 1;
      ++$applets;
   }

# count internal hyperlinks
   $inz = $iny;

   # get internal href targets
   while ($inz =~ /<a[^>]+?href="([^:>"]+)"[^>]*>(.*)/is) {
      $inz = $2;
      $url = $1;
      if (substr($url,0,7) eq "./sgml/") {
         $url = substr($url,2);
      }
      if (substr($url,0,1) eq "#") {
         $url = "${dirPrefixSlash}$filenameNodir$url";
      } elsif ($dirPrefix ne "") {
         if (substr($url,0,3) eq "../") {
            $url = substr($url,3);
         } elsif ($url !~ /\//) {
            $url = "${dirPrefixSlash}$url";
         } else {
            print("What is this? \"$url\" in: ${file}?\n");
         }
      }
 
      if (!(defined $ilinks{$url})) {
         $url =~ /^([^#]+)(.*)?/;
         $urlBase = $1;
         $qualifier = $2;
         if (defined $filesused{$urlBase}) {
            $filesused{$urlBase} = 1;
         }
         if (length($qualifier) > 0) {
            if ($qualifier !~ /^\#[a-zA-Z0-9]+$/) {
               print " $linenr. unused char in file name qualifier: $url\n";
               ++$linenr;
            }
         } 
         $ilinks{$url} = 1;
      }
      if ($url eq "Bradsmap.html" || $url eq "sitetoc.html" ||
                                 substr($url,0,12) eq "welcome.html" || substr($url,0,18) eq "welcome-XHTML.html" ||
                         $url eq "copyright.html" || $url eq "duty.html" || $url eq "changelog.html" ||
                         $url eq "signgb.html" || $url eq "everyman.html" || $url =~ /^quotesToc1?\.html$/ ||
                         $url eq "BorgesIndex.html" || $url eq "myWebArt.html" || $url eq "iconGallery.html" ||
                         $url eq "sq/shipwreck.html") {
         ++$fi_TemplateLinks;
      } else {
         ++$fi_links;
      }
   }

   # validate <select hrefs in Bradsmap big file chooser list

   if ($file eq "Bradsmap.html") {
      $iny =~ /\<select name\=\"infile\"(.*?)\<\/select\>/s;
      $BO = $1;
      $BOx = $BO;
      $BOx =~ s/[^\x0a]//gis;
      $BOx = length($BOx);
      $box = 0;
      while ($BO =~ /\<option( selected)? value\=\"([^"]+)\"\>(\- \- |\&nbsp;\&nbsp;\&nbsp;).*?\n(.*)/is) {
         $BO  = $4;
         $url = $2;
         if ($url eq "http://remember.org/") {
         } elsif (!(defined $ilinks{$url})) {
            $url =~ /^([^#]+)/;
            $urlBase = $1;
            if (defined $filesused{$urlBase}) {
               $filesused{$urlBase} = 1;
            }
            $ilinks{$url} = 1;
         }
         ++$bos;
      }
      if (!(($bos > 120) && ($bos + 1 == $BOx) && ($BO eq ""))) {
          print " $linenr. Bradsmap big file chooser list bad: $bos ? $BOx\n          \"$BO\"\n";
          ++$linenr;
      }
   } elsif ($file eq "gb.html") {
      if ($iny =~ /\>\[(\d{3,})\]\</s) {
        $nrguestbookentries = $1;
      } else {
        $nrguestbookentries = "?";
      }
   }

# count external hyperlinks
   $inz = $iny;
   while ($inz =~ /<a[^>]+?href="([^:>"]+:[^>"]+)"[^>]*>(.*)/is) {
      $url = $1;
      $inz = $2;
      if ($url =~ /cloud9\.net\/(\~|\%7[eE])bradmcc/) {
         ++$fia_links;
         # check for valid index numbers and alt-return targets in vuImagX.pl invocations
         if ($url =~ /cgi-bin\/vuImag([e2345])\.pl(.*)$/) {
            $vuIx = $1;
            $vuImageI = $2;
            if ($vuImageI !~ /^\?i=(\d+)(\$([-a-zA-Z0-9_%.\/]+)\$)?$/) {
               print " $linenr. Text error (210. Bad vuImagX.pl parameter: \"$vuImageI\"): $file\n";
               ++$linenr;
            } else {
               $vuImageN = $1;
               $vuImageTgt = $3;
               if ($vuImageN !~ /^[1-9]\d*$/ || $vuImageN < 1 || ($vuIx < 5 && $vuImageN > $vuMax) ||
                          ($vuIx >= 5 && $vuImageN > $vuMax5)) {
                  print " $linenr. Text error (220. Bad vuImagX.pl index: \"$vuImageN\"): $file\n";
                  ++$linenr;
               }
               if (length("$vuImageTgt ") > 1) {
                  $vuImageTgt =~ s/\%23/\#/g;
                  if (defined $filesused{$vuImageTgt}) {
                     $filesused{$vuImageTgt} = 1;
                  }
                  $ilinks{$vuImageTgt} = 1;
               }
            }
         } elsif ($url =~ /cgi-bin\/ascii\.pl\?f(ilename)?=([^"]+)/) {
            $ascF = $2;
            if ($ascF ne "cgi-bin/subs") {  # ignore subs
               if (defined $filesused{$ascF}) {
                  $filesused{$ascF} = 1;
               }
               $ilinks{$ascF} = 1;
            }
         }
      } else {
         if ($url =~ /validator\.w3\.org/i || $url eq "http://www.cl.cam.ac.uk/~mgk25/iso-time.html" ||
                  $url eq "http://www.nytimes.com/") {
            ++$ignored_Xlinks;
         } else {
            ++$fx_links;
         }
         $xlinks{$url} = 1;
      }
   }

# count action forms
   $inz = $iny;
   $inz =~ s/<form +action="[^>"]+"/(++$fx_forms)/gies;


# ************ count internal images (excluding sp.gif, etc.) ************

   $inz = $iny;
   while ($inz =~ /<img[^>]+?src="([^:>"]+)"([^>]*)>(.*)/is) {
      $inz = $3;
      $img = $1;
      $imginfo = $2;
      if ($imginfo !~ /(HEIGHT|height)=/s || $imginfo !~ /(WIDTH|width)=/s) {
         print " $linenr. File $file has image missing parameter(s): $img\n";
         ++$linenr;
      }
      if ($imginfo !~ /(ALT|alt)="([^]\n"]+)(.)/s) {
         print " $linenr. File $file has missing alt parameter(s)\n";
         ++$linenr;
      } elsif ("$3" eq "\n") {
         print " $linenr. File $file has bad alt parameter(s): \"${2}\"\n";
         ++$linenr;
      }
      if ($dirPrefix ne "") {
         if (substr($img,0,3) eq "../") {
            $img = substr($img,3);
         } elsif ($img !~ /\//) {
            $img = "${dirPrefixSlash}$img";
         }
      }
      if (!(defined $filesused{$img})) {
         print " $linenr. File $file has unknown image: $img\n";
         ++$linenr;
         next;
      }
      $filesused{$img} = 1;

      if ($img =~ /^gif\/[a-z]\.gif$/) {
         ++$dropCapImages;
      } elsif (($isSP = $imagesToIgnore{$img}) == 2) {
         ++$spacerImages;
      } elsif ($isSP == 1) {
         ++$iconImages;
      } else {
         $iphotos{$img} = 1;
         ++$fi_images;
      }
   }

# Count files that still have <font size=...
   if ((substr($file,0,9) eq "historic\\" && $file ne "historic\\linktarget.html") || $file eq "heuristic.html" ||
          $file =~ /^clarchive[1-6]\.html$/ || $file =~ /^gbarchive[1-4]\.html$/ || $file =~ /^5066\-1A\\gl(_archive1)?\.html$/) {
   } elsif ($iny =~ /\<font size\=/is || $iny =~ /\<font color=\"?[^ ">]+\"? size\=/is) {
      $fontSizeEqFiles++;
   }

# count external images
   $inz = $iny;
   $inz =~ s/<img[^>]+?src="[^:>"]+:[^>"]+"/(++$fx_images)/geis;

#---- do not count "inventory" pages in counts of *meaningful* links, etc. ----

   if ($file =~ /^titles\d?\.html$/ || $file eq "sitetoc.html" || $file eq "iconGallery.html" || $file eq "gibberish.html" ||
          $file =~ /quotesToc\d?\.html/ || $file eq "BorgesIndex.html" || $file =~ /\-1997\.html$/ ||
          $file eq "myWebArt.html" || $file eq "welcome-XHTML.html") {
      ++$notInAvg;
      $ignoredLinks += $fi_links;
      $fnColor{$file} = "black";
   } else {
      $i_links += $fi_links;
      $fnColor{$file} = "maroon";
   }
   $ignoredLinks += $fi_TemplateLinks;
   $i_images += $fi_images;
   $ia_links += $fia_links;
   $x_links += $fx_links;
   $x_images += $fx_images;
   $x_forms += $fx_forms;

   if ($fi_links < 6) {
      $pageFlags .= $fi_links;
   }
   $fn{$title} = $file;
   $x = length $in;
   $sigma_chars += $x;
   $x =~ s/(\d)(\d{3})$/\1,\2/;
   $fia_links = $fia_links > 0 ? ".$fia_links" : "";
   $fx_links = $fx_links > 0 ? ":$fx_links" : "";
   $fx_images = $fx_images > 0 ? ":$fx_images" : "";
   $fx_forms = $fx_forms > 0 ? "+$fx_forms" : "";
   if ($pageFlags ne "") {
      $pageFlags = "<font color=red><b>$pageFlags</b></font>";
   }
   $fnetc{$title} = "\&nbsp;${isCounted}| <i>$hasdoctype$hascontenttype $x$desclen. $fi_images$fx_images. " .
                       "${fi_links}+${fi_TemplateLinks}$fia_links$fx_links$fx_forms</i> |$pageFlags|\&nbsp;";
}
@files = ();

$sigma_chars =~ s/(\d)(\d{3})$/\1,\2/;
$sigma_chars =~ s/(\d)(\d{3},)/\1,\2/;

$diffiphotos = 0 + (keys %iphotos);
$diffxlinks = 0 + (keys %xlinks);
$diffilinks = 0 + (keys %ilinks);

$avg = $i_links / ($f_count - $notInAvg);  # do not count do-not-count files for avg
$avg2 = $avg;
$avg2 =~ s/\.(\d\d)\d*$/.$1/;
$avg =~ s/\.(\d)\d*$/.$1/;
$rawIlinks = $i_links;
$i_links =~ s/(\d)(\d{3})$/$1,$2/;
$x_links =~ s/(\d)(\d{3})$/$1,$2/;
$i_images =~ s/(\d)(\d{3})$/$1,$2/;
$diffilinks =~ s/(\d)(\d{3})$/$1,$2/;
$diffiphotos =~ s/(\d)(\d{3})$/$1,$2/;

#------------------- Control number of pages output is to be split into! --------

@titlesRelativeFileName = (
  "titles1.html",
  "titles2.html",
  "titles3.html",
  "titles4.html",
  "titles5.html",
  "titles6.html",
  "titles7.html",
  "titles8.html"
);
$numberOfSplits = @titlesRelativeFileName;

@filesOnPage = (0,0);
$fopIndex = 0;

pageHeader(1,$numberOfSplits);

$itemsOut = 0;
$split = int($f_count / $numberOfSplits);
foreach $title (sort mysortseq keys %fn) {
   $f = $fn{$title};
   $color= $fnColor{$f};
   $signpost = "";
   $icon = "src=\"GO/docimg.gif\" height=16 width=14";
   if ($f eq "Bradsmap.html") {
      $signpost = "<a href=\"Bradsmap.html\"><img src=\"signpost.gif\" align=right height=32" .
               " width=33 hspace=3 border=0 alt=\"[ Go to Site Map! ]\"></a>";
   } elsif ($f eq "changelog.html") {
      $signpost = "<a href=\"changelog.html\"><img src=\"WhatsNew.gif\" align=right height=54" .
               " width=73 hspace=3 border=0 alt=\"[ Change Log: What's new here? ]\"></a>";
   } elsif ($f eq "sgmlnote.html" || $f eq "panorama-1.html") {
      $signpost = "<a href=\"${f}\"><img src=\"gif/sgml.gif\" align=right height=32" .
               " width=32 hspace=3 border=0 alt=\"[ Learn more about SGML! ]\"></a>";
   } elsif ($f eq "Y2kGreeting.html") {
      $signpost = "<a href=\"Y2kGreeting.html\"><img src=\"gif/etna_erupting.gif\" height=50" .
               " width=50 hspace=3 border=0 alt=\"[ Go into the new Millennium! ]\" align=right></a>";
   } elsif ($f eq "NYTpermission.html") {
      $signpost = "<a href=\"NYTpermission.html\"><img src=\"gif/nyt165.gif\" height=28" .
               " width=165 hspace=4 border=0 alt=\"[ Go into the new Millennium! ]\" align=right></a>";
   } elsif ($f eq "square-1.html") {
      $signpost = "<a href=\"square-1.html\"><img src=\"gif/Albers_mini.gif\" height=26" .
               " width=26 hspace=3 border=1 alt=\"[ View e-Homage to the Square v-exhibit! ]\" align=right></a>";
   } elsif ($f eq "isadore.html" || $f eq "isadore2.html") {
      $signpost = "<a href=\"${f}\"><img src=\"jpg/StarAndBar_thumb.jpg\" height=42" .
               " width=78 hspace=3 border=0 alt=\"[ Learn how the Star acquired Bars and saved lives! ]\" align=right></a>";
   } elsif ($f eq "iconGallery.html") {
      $signpost = "<a href=\"iconGallery.html\"><img src=\"gif/icon.gif\" height=23" .
               " width=24 vspace=1 hspace=5 border=0 alt=\"[ visit website Icon Gallery! ]\" align=right></a>";
   } elsif ($f eq "GO\\paperTowels.html" || $f eq "GO\\mensRoom.html") {
      $signpost = "<a href=\"${f}\"><img src=\"gif/garbageCan.gif\" height=16" .
               " width=13 vspace=1 hspace=5 border=0 alt=\"[ Where do your throw your used paper towels in the restroon? ]\" align=right></a>";
      $signpost =~ s/\\/\//g;
   } elsif ($f eq "clock.html") {
      $signpost = "<a href=\"clock.html\"><img src=\"gif/clock.gif\" height=34" .
               " width=34 vspace=1 hspace=5 border=0 alt=\"[ What time does your computer think it is? Find out here! ]\" align=right></a>";
   } elsif ($f eq "survey.html" || $f eq "gif\\OSayCanUSee.html") {
      $icon = "src=\"gif/vote.gif\" height=15 width=15";
   } elsif ($f =~ /^(GeorgeWBush\d?|PR20020709|trifecta|troika|GO\\DarknessReturns)\.html$/) {
      $icon = "src=\"gif/garbageCan.gif\" height=16 width=13";
   } elsif ($f eq "AmCulture.html") {
      $icon = "src=\"gif/united_states.gif\" height=17 width=24";
   } elsif ($f eq "sq\\dumb.html") {
      $icon = "src=\"sq/warn.gif\" height=16 width=16";
   } elsif ($f eq "sq\\cycle.html") {
      $icon = "src=\"sq/small_cycle.gif\" height=12 width=18";
   }
   $fnn = $fn{$title};
   $fnn =~ s/\\/\//g;
   $f =~ s/\\/\//g;
   $bottom = (++$itemsOut + 2) % $split == 0 ? " name=\"bottom\"" : "";
 
   if ($fnn eq "VRMLctl.html" || $fnn eq "VRMLworld.html" || $fnn eq "VRMLeveryman.html") {
      $fnnn = "VRMLworld.html";
   } elsif ($fnn eq "myentry.html") {
      $fnnn = "welcome.html";
   } else {
      $fnnn = $fnn;
   }
   $descr = $description{$title};
   if ($f eq "welcome.html") {
      $descr =~ s/Erasmus/<a href="sq\/erasmus.html">Erasmus<\/a>/i;
   }
   $BBB = ($BB = $itemsOut % $split == 1) ? " nowrap>\&nbsp;\&nbsp;\&nbsp;" : "> ";
   $BB = $BB ? "<big>\&nbsp;</big>" : " ";
   $fnnnNoFt = $fnnn;
   $fnnnNoFt =~ s/\.html$//;
   $descr =~ s/\n/<font color=blue>&sect;<\/font>/gs;
 
   print OUT<<"EOFEOF";
<tr>
<td valign=top rowspan=2 align=right nowrap><big><b>&nbsp;</b><a$bottom href="$fnnn"><img $icon alt="[ $fnnnNoFt! ]" border=0></a></big></td>
<td rowspan=2>$BB</td>
<th valign=top align=left colspan=2><big><font color=$color>$title</font></big></th></tr>
<tr><td$BBB</td><td align=left>$signpost<i><b>${f}</b></i> $fnetc{$title}$descr</td></tr>
EOFEOF
   ++$filesOnPage[$fopIndex];

   if ($itemsOut % $split == 0) {
      $i = int($itemsOut / $split);
      if ($i < $numberOfSplits) {
         ++$fopIndex;
         pageFooter($i,$numberOfSplits);
         pageHeader($i+1,$numberOfSplits);   
      }
   }
}
pageFooter($numberOfSplits,$numberOfSplits);

if (!(open(FNU, "> titles.fnu"))) {
    print "Could not open titles.fnu\n";
    exit(16);
}
foreach $key (sort keys %filesused) {
   if ($filesused{$key} == -1) {
      print FNU "$key\n";
   } elsif ($filesused{$key} == 1) {
      $keyW = $key;
      $keyW =~ s/\//\\/g;
      $nodups{$keyW} = 1;
   } else {
      print " $linenr. filesused value= " . $filesused{$key} . ": \"${key}\"\n";
      ++$linenr;
   }
}

close (FNU);

# avoid doing a lot of SSIs in dissert.html to get file sizes

$iconImages =~ s/(\d)(\d{3})$/$1,$2/;

$oldmyentryFile = $myentryFile;

$vC = $vCount == 0 ? "\&nbsp;" : "v-$vCount ";

$vocabuCount = 0;
$spImageCount = 0;
foreach $key (keys %imagesToIgnore) {
   if ($imagesToIgnore{$key} == 1) {
      ++$vocabuCount;
   } elsif ($imagesToIgnore{$key} == 2) {
      ++$spImageCount;
   } else {
      print "Unknown icon hash value $imagesToIgnore=$imagesToIgnore{$key}.\n";
      exit (16);
   }
}
$gbRate = $nrguestbookentries / (($starttime - 849572637) / 604800); #[0] 1996.12.03 @ 00:23:57 GMT / gb entries per week
$gbRate =~ s/(\d\.\d{2})\d+$/$1/;

$cdate = "$now<br>$system. $version";

if ($myentryFile !~ s/\<\!\-\- ILINK \-\-\>[\d,]+\<\!\-\- \/ILINK \-\-\>/<!-- ILINK -->${i_links}<!-- \/ILINK -->/s ||
       $myentryFile !~ s/\<\!\-\- HTOT \-\-\>[\d,]+\<\!\-\- \/HTOT \-\-\>/<!-- HTOT -->${f_count}<!-- \/HTOT -->/s ||
       $myentryFile !~ s/\<\!\-\- NOV \-\-\>(v\-[\d,]+ |\&nbsp;)\<\!\-\- \/NOV \-\-\>/<!-- NOV -->${vC}<!-- \/NOV -->/s ||
       $myentryFile !~ s/\<\!\-\- XLINK \-\-\>[\d,]+\<\!\-\- \/XLINK \-\-\>/<!-- XLINK -->${diffxlinks}<!-- \/XLINK -->/s ||
       $myentryFile !~ s/\<\!\-\- AVG \-\-\>[\d.]+\<\!\-\- \/AVG \-\-\>/<!-- AVG -->${avg}<!-- \/AVG -->/s ||
       $myentryFile !~ s/\<\!\-\- ICONS \-\-\>[\d,]+\<\!\-\- \/ICONS \-\-\>/<!-- ICONS -->${iconImages}<!-- \/ICONS -->/s ||
       $myentryFile !~ s/\<\!\-\- CDATE \-\-\>.*?<\!\-\- \/CDATE \-\-\>/<!-- CDATE -->${cdate}<!-- \/CDATE -->/s ||
       $myentryFile !~ s/\<\!\-\- GBE \-\-\>.*?<\!\-\- \/GBE \-\-\>/<!-- GBE -->${nrguestbookentries}<!-- \/GBE -->/s ||
       $myentryFile !~ s/\<\!\-\- GBE2 \-\-\>.*?<\!\-\- \/GBE2 \-\-\>/<!-- GBE2 -->${gbRate}<!-- \/GBE2 -->/s ||
       $myentryFile !~ s/\<\!\-\- ICOUNT \-\-\>[\d,]+\<\!\-\- \/ICOUNT \-\-\>/<!-- ICOUNT -->${vocabuCount}<!-- \/ICOUNT -->/s) {
   print "myentry.html Bad\n";
   exit (16);
}
if ($oldmyentryFile ne $myentryFile) {
   if (!open(SIZE, "> ${basedir}\\myentry.html")) {
      print "** Could not open output myentry.html\n";
      exit (16);
   }
   print SIZE $myentryFile;
   close SIZE;
}

# ==== Write footnote trigger info into last footnotes file ====

if (!open(F, "< ${basedir}\\footnotes${maxfnpage}.html")) {
   print "** Could not open input footnotes${maxfnpage}.html\n";
   exit (16);
}
read F, $data, 60000;
close (F);
$data0 = $data;
$data =~ /.+\<a name\=\"fn(\d+)\" /s;
$newratio = $fntriggers / ($fnct = $1);  # footnote 20 was deleted; but there are 2 #61's
$newratio =~ s/\.(\d\d)\d+/.${1}/;
$mtfna = "<a href=\"footnotes${mtfnpg}.html\#fn$mtfnid\">"; 
if ($data !~ s/\<\!\-\- MULTI \-\-\>\d+(\.\d+)?\<\!\-\- \/MULTI \-\-\>/<!-- MULTI -->${newratio}<!-- \/MULTI -->/s ||
     $data !~ s/\<\!\-\- MAXI \-\-\>\d+\<\!\-\- \/MAXI \-\-\>/<!-- MAXI -->${maxTriggers}<!-- \/MAXI -->/s ||
     $data !~ s/\<\!\-\- MTFNID \-\-\>\d+\<\!\-\- \/MTFNID \-\-\>/<!-- MTFNID -->${mtfnid}<!-- \/MTFNID -->/s ||
     $data !~ s/\<\!\-\- A \-\-\>.*?\<\!\-\- \/A \-\-\>/<!-- A -->${mtfna}<!-- \/A -->/s) {
   print "footnotes${maxfnpage}.html Bad\n";
   exit (16);
}
if ($data0 eq $data) {
} elsif (!open(F, "> ${basedir}\\footnotes${maxfnpage}.html")) {
   print "** Could not open output footnotes${maxfnpage}.html\n";
   exit (16);
} else {
   print F $data;
   close (F);
}

# ==== Write current site link statistics into ObjektiveGeist.html ====

$prevIlinks = -1;
if (!open(F, "< ${basedir}\\ObjektiveGeist.html")) {
   print "** Could not open input ObjektiveGeist.html\n";
   exit (16);
}
read F, $data, 60000;
close (F);
$data0 = $data;
if ($data !~ s/\<\!\-\- DATE \-\-\>.*?\<\!\-\- \/DATE \-\-\>/<!-- DATE -->${today}<!-- \/DATE -->/s ||
       $data !~ s/\<\!\-\- AVG \-\-\>[\d.]+\<\!\-\- \/AVG \-\-\>/<!-- AVG -->${avg}<!-- \/AVG -->/s ||
       $data !~ s/\<\!\-\- HP \-\-\>[\d,]+\<\!\-\- \/HP \-\-\>/<!-- HP -->${f_count}<!-- \/HP -->/s ||
       $data !~ s/\<\!\-\- XLINK \-\-\>[\d,]+\<\!\-\- \/XLINK \-\-\>/<!-- XLINK -->${diffxlinks}<!-- \/XLINK -->/s ||
       $data !~ s/\<\!\-\- ILINK \-\-\>([\d,]+)\<\!\-\- \/ILINK \-\-\>/<!-- ILINK -->${i_links}<!-- \/ILINK -->/s) {
   print "ObjektiveGeist.html Bad\n";
   exit (16);
}
$prevIlinks = $1;
$prevIlinks =~ s/,//g;
if ($data0 eq $data) {
} elsif (!open(F, "> ${basedir}\\ObjektiveGeist.html")) {
   print "** Could not open output ObjektiveGeist.html\n";
   exit (16);
} else {
   print F $data;
   close (F);
}

if (!open(F, "< ${basedir}\\iconGallery.html")) {
   print "** Could not open input iconGallery.html\n";
   exit (16);
}
read F, $data, 60000;
close (F);
$data0 = $data;
if ($data !~ s/\<\!\-\- DATE \-\-\>[^<]+\<\!\-\- \/DATE \-\-\>/<!-- DATE -->${today}<!-- \/DATE -->/s ||
       $data !~ s/\<\!\-\- ICONS \-\-\>[\d,]+\<\!\-\- \/ICONS \-\-\>/<!-- ICONS -->${iconImages}<!-- \/ICONS -->/s ||
       $data !~ s/\<\!\-\- HP \-\-\>[\d,]+\<\!\-\- \/HP \-\-\>/<!-- HP -->${f_count}<!-- \/HP -->/s ||
       $data !~ s/\<\!\-\- ICOUNT \-\-\>[\d,]+\<\!\-\- \/ICOUNT \-\-\>/<!-- ICOUNT -->${vocabuCount}<!-- \/ICOUNT -->/s) {
   print "iconGallery.html Bad\n";
   exit (16);
}
if ($data0 eq $data) {
} elsif (!open(F, "> ${basedir}\\iconGallery.html")) {
   print "** Could not open output iconGallery.html\n";
   exit (16);
} else {
   print F $data;
   close (F);
}

#$sumline2 = ""; # non-HTML files used to be processed here. Now they are processed at the top
                 # so that the .inc SGML files can furnish information to the AUDIT file's
                 # last page's footer.

if ($linenr != 1) {
   print "\n";
}

if (!open(AUDIT, ">${basedir}\\$auditFN")) {
   print "** Open failed for log file: $auditFN\n";
   exit(16);
}
$count = @audit;
print AUDIT "* $now.  Perl: " . $] . ".  $auditFN   $basedir\n";
print AUDIT "\n";

if ($d_count != $f_count) {
   $haveD = "*** $d_count have doctype / ";
} else {
   $haveD = "";
}
if ($t_count != $f_count) {
   $haveT = "*** $t_count have META description / ";
} else {
   $haveT = "";
}
if ($content_type_no != 0) {
   $content_type_all = $content_type_no + $content_type_yes;
   $haveC = "*** $content_type_yes of $content_type_all have META content-type / ";
} else {
   $haveC = "";
}

# List files for addSizes.pl

open(IL, "> ${basedir}\\LS.ilinks");
foreach $key (keys %nodups) {
   $key =~ s/\//\\/g;
   print IL "$key\n";
}
close (IL);

$unresolved = 0;
foreach $key (keys %ilinks) {
   if (defined $htmlfiles{$key}) {
      next;
   }
   if (defined $filesused{$key}) {
      next;
   }
   if (!(defined $inames{$key})) { # && $key ne "amcx.pl?i=26") { # vuImag4.pl #215 defunct, I hope!
      $keyx = $key;
      $keyx =~ s/([^a-zA-Z0-9])/\\$1/g;
      print "  >> Unresolved internal link: $key\n";
      $unresolved = 1;
   }
}

if ($unresolved != 0) {
   print "\n\n";
} elsif ($linenr != 1) {
   print "\n";
}

print "   $f_count processed ($countedFiles counted) html files; $sigma_chars chars.  Perl: " . $] . ".\n";
print " ($unprocessed unprocessed dir entries; $subsubdirhtml html files in sub-subdirs).  hpRegX=${hpRegXlen}(+${hpRegX2len}.\n\n";

print "titles";
$fop = -1;
for ($i=0; $i < $numberOfSplits; ++$i) {
   $tflen = -s $basedir . "\\" . $titlesRelativeFileName[$i];
   $tflen += 50;  # (round)
   $tflen =~ s/(\d)\d{2}$/,$1/;
   if ($filesOnPage[$i] != $fop) {
      $fop = $filesOnPage[$i];
      $fopp = $fop;
   } else {
      $fopp = "";
   }
   print " " . ($i + 1) . " " . $fopp . "(" . $tflen . " ";
}
print "\n";
$sumline2 =~ s/MAXSUM/${maxSum}/;

print AUDIT $sumline2 . "\n$i_images int img. $x_images ext img. $i_links int rlnk. $ia_links int alnk. $x_links ext lnk\n" .
         "$iconImages icons $dropCapImages dropCaps + $spacerImages sp.  $ignoredLinks + $ignored_Xlinks ignored i/x_links.  $count files:\n\n";

$dirPrev = "";
foreach $item (sort mysortseq2 @audit) {
   if ($item =~ /([^\\]+)\\/) {
      if ($1 ne $dirPrev) {
         $dirPrev = $1;
         print AUDIT "\n";
      }
   } else {
      if ($dirPrev ne "") {
         $dirPrev = "";
         print AUDIT "\n\n";
      }
   }
   print AUDIT $item . "\n";
}
print AUDIT "\nEND $i_links $ignoredLinks END\n";
close (AUDIT);

$idelta = $rawIlinks - $prevIlinks;
if ($idelta == 0) {
   $idelta = "";
} else {
   if ($idelta > 0) {
      $idelta = "+$idelta";
   }
   $idelta = " ($idelta)";
}
if ($vCount > 0) {
   $vCount = "v-" . $vCount . ". ";
} else {
   $vCount = "";
}

$spacerImages =~ s/(\d)(\d{3})$/$1,$2/;
$totIlinks = $rawIlinks + $ignoredLinks;
$countedPct = (($rawIlinks / $totIlinks) * 100) + 0.005;
$countedPct =~ s/\.(\d{2})\d+$/.$1/;
$ignoredLinks =~ s/(\d)(\d{3})$/$1,$2/;
$vct = $v_count + $v40_count;
$bo = $f_count == $bodySilver + $bodyLgrey + $bodyOther + $bodyNo ? "" : "?";
$totIlinks =~ s/(\d)(\d{3})$/$1,$2/;
$ild = $rawIlinks < 10000 ? " " : "";
$fwfz = $fontSizeEqFiles == 0 ? ".\n" : "\n" . (" " x 56) ."Files w/font size: ${fontSizeEqFiles}.\n";

# audit <DOCTYPE tags

@dcounts = ();
print LOG "\n\n";
foreach $doctype (keys %doctypes) {
   $dct = $doctypes{$doctype};
   push @dcounts, (99999 - $dct) . substr("    ", 0, 4 - length($dct)) . "$dct. $doctype\n";
}
$dCT = "";
$dSEP = "";
foreach $doctype (sort @dcounts) {
   print LOG substr($doctype, 5);
   $doctype =~ /(\d+)\./;
   $dCT .= "$dSEP$1";
   $dSEP = "+";
}

$summaryInfo = "${haveD}${haveT}${haveC}\n" .
   "   $vct mkd valid 3.2/4: ${v_count}+$v40_count ($dCT).  ${vCount}$avg2 links/page.  t/fn: $newratio/$fnct.\n" .
   "    $applets ~JAVA applets.  $x_forms action forms.  bodyColor Si/Lg/_/? $bodySilver/$bodyLgrey/$bodyOther/$bodyNo$bo.\n" .
   " $i_images ($diffiphotos diff), $iconImages/$vocabuCount ic + $dropCapImages dC + $spacerImages/$spImageCount sp int; $x_images ext images.\n" .
   "$ild$i_links rel$idelta ($diffilinks diff), $ia_links abs i_links.  ${ignoredLinks}(/$notInAvg) + $ignored_Xlinks ignored i_/x_links.\n" .
   " $x_links ($diffxlinks diff) x_links.  $vuLinks (+${vuLinksI}i ${vuLinksX}x ${vuLinksR}r) images+links in vuImagX+amcx$fwfz";
print $summaryInfo;

@t=localtime($stoptime = time());
$et = $stoptime - $starttime;
$now=sprintf("%s.%02d.%02d at: %02d:%02d:%02d %s",
            $t[5]+1900,$t[4]+1,$t[3],$t[2],$t[1],$t[0],($t[8]==0?"EST":"EDT"));
print "\n  \"$system\" $basedir  >> $now\n  $et secs e/t.   ";

if ($doVerifyTableTags) {
   $GKWcolors = "";
   $i = 0;
   foreach $color (sort keys %colors) {
      if ($colors{$color} != 3) {
         $GKWcolors .= ($color . (" " x (15 - length($color))));
         if (++$i == 5) {
            $GKWcolors .= "\n";
            $i = 0;
         }
      }
   }
   if ($GKWcolors ne "" && $GKWcolors ne "</b            ") {
      print "\n\n" . $GKWcolors . "\n";
   }
}

# 2008. 2005.04.01 @ 06:26:13 EST  408p 1,312ii 9,391+5,018r/594ai 1,584xl  8,081,890

if (!open(LOG2,"< ${basedir}\\titles.ctr")) {
   print "Open input failed for ${basedir}\\titles.ctr\n";
   exit 16;
}
read(LOG2, $in, 250000);
$inLen = length($in);
close (LOG2);
$inEnd = " " . substr($in, -120);
while ($inEnd =~ s/^(\d+)\. /?/m) {
   $ix = $1;
}
if (!open(LOG2,">> ${basedir}\\titles.ctr")) {
   print "Open append failed for ${basedir}\\titles.ctr\n";
   exit 16;
}
$now =~ s/at:/\@/;
print LOG2 ($ix + 1) . ". $now  ${f_count}p ${i_images}ii ${i_links}+${ignoredLinks}r/${ia_links}ai ${x_links}xl  $sigma_chars\n";
close LOG2;

$inLen =~ s/(\d)(\d{3})$/$1,$2/;
$ix =~ s/(\d)(\d{3})$/$1,$2/;
print $^O ."  ctr: $ix($inLen).  [ $totIlinks ${countedPct}% ]  Gb: $nrguestbookentries (${gbRate}/w.\n";

if (length($fpat) > 0) {
    print LOG $fpat;
}

close LOG;
exit 0;


#------------------ Subroutines -------------

#**
sub mysortseq {

   my ($mya, $myb);
   $mya = $a;
   $mya =~ tr/a-z/A-Z/;
   $mya =~ s/\&IQUEST;/?/g;
   $mya =~ s/\&LT;/</g;
   $mya =~ s/\&GT;/>/g;
   $mya =~ s/\&AMP;/\&/g;
   $mya =~ s/^([\W_]+)?((AN|A|THE)\s+)?//;   # "A.-L. Breguet..."
   $mya =~ s/^SOME //;
   $myb = $b;
   $myb =~ tr/a-z/A-Z/;
   $myb =~ s/\&IQUEST;/?/g;
   $myb =~ s/\&LT;/</g;
   $myb =~ s/\&GT;/>/g;
   $myb =~ s/\&AMP;/\&/g;
   $myb =~ s/^([\W_]+)?((AN|A|THE)\s+)?//;
   $myb =~ s/^SOME //;
   return ($mya cmp $myb);
}


#**
sub mysortseq2 {

   my ($mya, $myb, $aSub, $bSub);
   $mya = $a;
   $mya =~ tr/a-z/A-Z/;
   $myb = $b;
   $myb =~ tr/a-z/A-Z/;
   $aSub = $mya =~ /\\/;
   $bSub = $myb =~ /\\/;
   if ($aSub && !$bSub) {
      return -1;
   }
   if ($bSub && !$aSub) {
      return 1;
   }
   return ($mya cmp $myb);
}


#**
sub getfilenames {

   my ($subdirname) = @_;
   my (@thesefiles, $myitem, $dirname, $item, $myfullitem);
   $dirname = "$basedir\\$subdirname";
   opendir(INDIR, $dirname);
   @thesefiles = readdir(INDIR);
   closedir(INDIR);
   foreach $item (@thesefiles) {
      $myitem = $subdirname.$item;
      $myfullitem = "$basedir\\$myitem";
      if (-d $myfullitem) {
         if ($item =~ /^\.\.?$/) {
            next;
         }
         getfilenames($myitem."\\");
         next;
      }
      if (!(-f $myfullitem)) {
         print " $linenr. Unknown directory entry: $myfullitem\n";
         ++$linenr;
         next;
      }
      $myitemW = $myitem;
      $myitem =~ s/\\/\//g;     # change file names to UNIX format: a/b/c
      push @files, $myitem;
      if ($myitem =~ /\.html$/) {
         $htmlfiles{$myitem} = 0;
         $nodups{$myitemW} = 1;
         next;
      }
      if ($myitem =~ /.htm$/) {
         print " $linenr. .htm file detected: $myfullitem\n";
         ++$linenr;
         next;
      }
      if ($myitem !~ /^((240|5(015|066\-1A)|BWRaymond|g(if|eocities)|GO|lcp|archive|historic|jpg|mimi|moon|s(gml|q)|WPM|cgi\-bin)\/)?[a-zA-Z0-9\-\._]+$/) {
         print " $linenr. unused char in file name: $myfullitem\n";
         ++$linenr;
         next;
      }
      if ($myitem =~ /\.inc$/ && $item !~ /^(std|warn)/) {
         push @incFiles, $myitem;
      }
      $filesused{$myitem} = -1;
   }
}


#**
sub pageHeader {

   my ($i, $n) = @_;
   open(OUT, "> $basedir\\$titlesRelativeFileName[$i - 1]");
   print OUT<<"EOFEOF";
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Website page inventory (Analytical Table of Contents) :: p.$i/$n</title>
<META NAME="description" CONTENT="Inventory $f_count HTML pages on this website; list titles, description META tag content;
generated by Perl script 'titles.pl', version: $version on: $system. p.$i/$n.">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#D3D3D3">
<table width="100%" cellspacing=0 cellpadding=0 border=0>
<tr><td valign=bottom><table cellspacing=0 cellpadding=0 border=0>
<tr><td valign=top><table cellspacing=0 cellpadding=0 border=0>
<tr><td rowspan=2><img src="sp.gif" border=0 height=2 width=2 hspace=1 alt="[ ]"></td>
<td><img src="sp.gif" border=0 height=2 width=2 vspace=3 alt="[ ]"></td></tr>
<tr><td><table cellspacing=3 cellpadding=0 border=1>
<tr><td><a href="sitetoc.html"><img src="sq/4x4_dn.gif" height=78 width=78 hspace=1 vspace=1 alt="[ Go to user-friendly Table of Contents! ]" border=0></a></td>
</tr></table></td></tr></table></td>
<td><img src="sp.gif" border=0 height=2 width=2 hspace=4 alt="[ ]"></td>
<td valign=top align=left nowrap><b><big><big><big><font color="navy">Website page inventory</font></big><br>
<font color="navy">(<i>Anaytical Table of Contents</i>)</font><br>
<big><font color="navy">p.$i/$n</font></big></big></big></b></td></tr>
<tr><td align=left valign=bottom colspan=3><table cellspacing=0 cellpadding=0 border=0>
EOFEOF
   if ($d_count == $f_count) {
      print OUT "<tr><td colspan=2>\&nbsp;</td></tr>\n";
   }
   print OUT<<"EOFEOF";
<tr><th valign=top align=right><big>$f_count</big></th>
<th valign=top align=left><big>&nbsp;HTML files.</big></th></tr>
<tr><td colspan=2><hr align=left width=150></td></tr>
EOFEOF
   if ($d_count != $f_count) {
      print OUT "<tr><th valign=top align=right><big>$d_count</big></th>\n" .
              "<th valign=top align=left><big>\&nbsp;have doctypes.</big></th></tr>\n";
   }
   print OUT<<"EOFEOF";
<tr><th valign=top align=right><big>$v_count</big></th>
<th valign=top align=left><big>&nbsp;marked
<i><A HREF="http://validator.w3.org/">valid HTML 3.2</a></i>.</big></th></tr>
<tr><th valign=top align=right><big>$v40_count</big></th>
<th valign=top align=left><big>&nbsp;marked
<i><A HREF="http://validator.w3.org/">valid HTML 4.0</a></i> ($v40s_count strict).</big></th></tr>
EOFEOF
   if ($t_count != $f_count) {
      print OUT "<tr><th valign=top align=right><big>$t_count</big></th>\n" .
              "<th valign=top align=left><big>\&nbsp;have descriptions.</big></th></tr>\n";
   }
   print OUT<<"EOFEOF";
</table></td>
</tr></table></td>
<td><img src="sp.gif" border=0 height=2 width=2 hspace=5 alt="[ ]"></td>
<td valign=bottom align=right><table cellspacing=0 cellpadding=0 border=0>
<tr><td align=right><table cellspacing=0 cellpadding=0 border=0>
<tr><td><table cellpadding=0 cellspacing=6 border=1>
<tr><td><a href="Bradsmap.html"><img src="gif/anim.gif" alt="[ Go to BMcC website Visual site map! ]"
width=120 height=120 border=0 vspace=1 hspace=1></a></td></tr></table></td>
<td><img src="sp.gif" height=2 width=4 vspace=4 hspace=2 border=0 alt="[ ]"></td></tr>
</table></td></tr>
<tr><td><img src="sp.gif" height=2 width=2 vspace=6 hspace=2 border=0 alt="[ ]"></td></tr>
<tr><td valign=bottom align=right><big><i>As of:</i> $now</big></td></tr>
</table></td></tr>
</table>
<hr>
EOFEOF
   if ($i > 1) {
      print OUT<<"EOFEOF";
<a href="$titlesRelativeFileName[$i-2]#bottom"><img src="gif/prev2a.gif" height=12 width=10 border=0 alt="[ &lt;&lt; ]"></a>
<big><i><b><a href="$titlesRelativeFileName[$i-2]#bottom">Return</a></b></i> to previous section of page inventory.</big>
<hr align=left width="40%">
EOFEOF
   }
   print OUT<<"EOFEOF";
<small><font color=purple><b><i><font color=black>Legend:</font></i>&nbsp;&nbsp; Name&nbsp; counted?<font color=black>|</font>&nbsp; pageLen<font color=black>:</font>descLen<font color=black>.</font>&nbsp; #intImages<font color=black>.</font>&nbsp; #intLinks<font color=black>+</font>#templateIntLinks<font color=black>.</font>#intAbslinks?<font color=black>:</font>#extLinks?&nbsp; #forms? <font color=black>|</font></b><font color=red>invalid?#links&lt;6?</font><b><font color=black>|</font> description </b>[<font color=blue>&sect;</font>='\\n']</font></small><br>
&nbsp;
<table cellspacing=1 cellpadding=0 border=0>
EOFEOF
}


#**
sub pageFooter {

   my ($i, $n) = @_;
   print OUT<<"EOFEOF";
</table>
<big>&nbsp;</big>
EOFEOF
   if ($i < $n) {
      print OUT<<"EOFEOF";
<hr align=left width="40%">
<big><i><b><a href="$titlesRelativeFileName[$i]">Go</a></b></i> to next section of page inventory<a href="$titlesRelativeFileName[$i]"><img src="gif/next2a.gif" height=12 width=10 hspace=3 alt="[ Go to next section of inventory! ]" border=0></a><br>
&nbsp;</big><br>
EOFEOF
   } else {
      print OUT<<"EOFEOF";
<table cellspacing=0 cellpadding=0 width="100%" border=0>
<tr><td align=left valign=top><form action="http://www.users.cloud9.net/~bradmcc/cgi-bin/tables.pl" method=GET><big>&nbsp;<br>
<big><i>SGML</i></big> tables of <i>BMcC</i> favorite: <select name="filename" size=1>
@{incFilesF}</select> <input type="submit" name="sub" value="Go!"></big></form></td>
<td><big>&nbsp;<br>
<big>&nbsp;</big><br>
&nbsp;</big></td></tr></table>
<hr align=left width="40%">
EOFEOF
   }
   $vuLinksT = $vuLinks + $vuLinksI + $vuLinksX;
   print OUT<<"EOFEOF";
<i>$sigma_chars</i> characters in <i>$f_count</i> HTML files.<br>
<i>$i_images</i> internal images (<i>$diffiphotos</i> different). <i>$x_images</i> external images.<br>
<i>$i_links</i> relative (<i>$diffilinks</i> different), <i>$ia_links</i> absolute internal links. <i>$x_links</i> (<i>$diffxlinks</i> different) external links.<br>
<i>$x_forms</i> action forms. Avg. links per page: <i>$avg</i>.   
<hr size=7>
<table cellspacing=0 cellpadding=0 border=0 width="100%">
<tr><td><big><a href="changelog.html">What's new</a> on this website?<br>
&nbsp;<br>
EOFEOF
   if ($i == 1) {
      $addCounter = "#exec cgi=\"cgi-bin/uctr9.pl\"";
      print OUT<<"EOFEOF";
<a href="titles${n}.html">Go</a> to last page of this <i>page inventory</i>.<a href="titles${n}.html"><img src="gif/next2a.gif" height=12 width=10 border=0 align=bottom hspace=2 alt="[ Go to last page of page inventory! ]"></a><br>
EOFEOF
   } else {
      if ($i == @titlesRelativeFileName) {
         $addCounter = "#exec cgi=\"cgi-bin/uctrC.pl\"";
      } else {
         $addCounter = " not counted ";
      }
      print OUT<<"EOFEOF";
<a href="titles1.html"><img src="gif/prev2a.gif" height=12 width=10 border=0 align=bottom hspace=2 alt="[ Return to beginning of page inventory! ]">Return</a> to first page of this <i>page inventory</i>.<br>
EOFEOF
   }
   print OUT<<"EOFEOF";
&nbsp;</big>
<table cellspacing=0 cellpadding=0 border=0>
<tr><td valign=top><big><a href="iconGallery.html">Examine</a></big></td>
<td><big>\&nbsp;"vocabulary list" display of navigational icon images used in this website.</big></td>
</tr></table></td>
<td valign=top align=right><a href="changelog.html"><img src="WhatsNew.gif" height=54 width=73 vspace=2 hspace=3
border=0 alt="[ Change Log: What's new here? ]"></a></td></tr>
</table>
<hr width="40%" align=left>
<table cellspacing=0 cellpadding=0 border=0 width="100%">
<tr><td valign=bottom align=left><big><a href="workspace.html">Return</a> to website <i>technical information</i> page.<br>
<a href="copyright.html">Read</a> &copy;opyright notice <b>+</b> <i>Terms and conditions of use</i>.<br>
&nbsp;<br>
<a href="sitetoc.html">Go</a> to website <i>Table of Contents</i>.<br>
<a href="welcome.html">Return</a> to Brad McCormick's home page.<br>
<a href="Bradsmap.html">Return</a> to site map.</big></td>
<td valign=bottom align=right><table cellspacing=0 cellpadding=0 border=0>
<tr><td rowspan=2><img src="sp.gif" height=2 width=2 hspace=3 alt="[ ]" border=0></td>
<td valign=bottom><a href="Bradsmap.html"><img src="signpost.gif" height=32 width=33 border=0 alt="[ Go to Site Map! ]"></a></td>
<td><img src="sp.gif" height=2 width=2 hspace=11 alt="[ ]" border=0></td>
<td valign=bottom><a href="sitetoc.html"><img src="gif/up_black.gif" vspace=1 height=16
width=16 border=1 alt="[ Go to website Table of Contents! ]"></a></td>
<td><img src="sp.gif" height=2 width=2 border=0 alt="[ ]" hspace=19></td>
<td rowspan=2 valign=bottom><a href="welcome.html"><img src="gif/home.gif" height=32 width=32 vspace=1 border=0 alt="[ Go home! (BMcC website Home page!) ]"></a></td>
<td rowspan=2><img src="sp.gif" height=2 width=2 border=0 alt="[ ]" hspace=5></td>
<td rowspan=2 valign=bottom><img src="gif/bv.gif" height=36 width=1 border=0 alt="[ | ]"></td>
<td rowspan=2><img src="sp.gif" height=2 width=2 border=0 alt="[ ]" hspace=3></td>
<td rowspan=2 valign=bottom><a href="iconGallery.html"><img src="gif/icon.gif" height=23 width=24 alt="[ Click me to visit website Icon Gallery! ]" vspace=2 border=0></a></td>
<td rowspan=2><img src="sp.gif" height=2 width=2 border=0 alt="[ ]" hspace=1></td></tr>
<tr><td colspan=4><img src="sp.gif" height=2 width=2 border=0 alt="[ ]" vspace=1></td></tr>
</table></td></tr></table>
<hr>
<table cellspacing=0 cellpadding=0 width="100%" border=0>
<tr><td valign=top align=left><table cellspacing=0 cellpadding=0 border=0>
<tr><td valign=top><table cellspacing=0 cellpadding=0 border=0>
<tr><td><a href="duty.html"><img src="gif/lighthousea.gif" height=104 width=41
alt="[ Go to: The duty of communicators! ]" border=1></a></td></tr>
<tr><td><a href="sq/shipwreck.html"><img src="GO/AOLman.gif" height=48 width=43 border=0 alt="[ Where is AOL man going? Where are you going? ]"></a></td></tr>
</table></td>
<td><img src="sp.gif" height=2 width=2 hspace=3 border=0 alt="[ ]"></td>
<td valign=top nowrap><address><font color=green>http://www.cloud9.net/~bradmcc/$titlesRelativeFileName[$i-1]<br>
(Page generated: $now,<br>
by <a href="http://www.users.cloud9.net/~bradmcc/cgi-bin/ascii.pl?filename=titles.pl">titles.pl</a>: $version)<br>
<a href="copyright.html">Copyright &copy;</a> 1998-2006 Brad McCormick, Ed.D.<br>
bradmcc\@cloud9.net <a href="signgb.html"><img src="gif/email2me.gif" border=0 align=bottom height=10 width=15 alt="[ Email me! ]"></a><br>
$today<!--${addCounter}--></font></address></td></tr></table></td>
<td><img src="sp.gif" border=0 hspace=4 alt="[ ]" height=2 width=2></td>
<td align=right valign=top><table cellspacing=0 cellpadding=0 border=0>
<tr><td align=right colspan=4><A HREF="http://validator.w3.org/check/referer"><IMG SRC="valid_html3_2.gif"
height=32 width=48 align=right hspace=3 vspace=2 border=0 ALT="[ HTML 3.2 Checked! Test me! ]"></A></td></tr>
<tr><td colspan=4><img src="sp.gif" border=0 vspace=21 alt="[ ]" height=2 width=2></td></tr>
<tr><td valign=top><a href="sgmlnote.html"><img src="gif/sgml.gif" height=32 width=32 align=right vspace=3 alt="[ Learn about SGML! ]" border=0></a></td>
<td><img src="sp.gif" border=0 hspace=8 alt="[ ]" height=2 width=2></td>
<td align=right><a href="sgmlnote.html"><img src="gif/noAcro.gif" height=104 width=90 border=0 alt="[ Stop proprietary document interchange software! ]"></a></td>
<td><img src="sp.gif" border=0 hspace=4 alt="[ ]" height=2 width=2></td></tr>
</table></td></tr>
<tr><td colspan=3><img src="sp.gif" border=0 vspace=2 alt="[ ]" height=2 width=2></td></tr></table>
</body>
</html>
EOFEOF
   close(OUT);
}


#**
sub getSize {

   my ($fileName, $format) = @_;
   my ($len);
   $fileName =~ s/\//\\/g;
   $len = -s $fileName;
   if ($len < 1) {
      print "---- getSize failed: $thisfileName >> $fileName $len\n";
      return 0;
   }
   if ($format eq "k") {
      $len = int(($len + 1023)/1024) . "k";
   } else {
      $len =~ s/(\d)(\d{3})$/$1,$2/;
   }
   return $len;
}


#**
sub chkSum {

   my ($in) = @_;
   my ($ix, $sum, $sum2, $shift);
   $shift = 1;
   $ix = length($in) - 1;
   for (; $ix >= 0; --$ix) {
      $chr = ord(substr($in, $ix, 1));
      $sum += $chr * ($shift++);
   }
   if ($sum > $maxSum) {
      $maxSum = $sum;
   }
   return $sum;
}


#**
sub chkLineEnds {

   my ($inData, $diskSize, $file) = @_;
   my ($inu, $nrLines);
   $inu = $inData;
   $inu =~ tr/AD\x0a\x0d/adAD/;
   $nrLines = -99999;
   if ($inu =~ /D/s || 0 != (length($inData) + ($nrLines = $inu =~ s/A/A/g) - $diskSize)) {
      print " $linenr. Text error (90. Bad lineEnd(s): $file\n";
      ++$linenr;
   }
   return $nrLines;
}


#**
sub parseRegex {

   my ($patternx) = @_;
   my ($fpat, $offset, $x, $segment);

#print "\n";

   $offset = 4;
   $x = 200;
   $patternx =~ s/\\\(/\xfe/gs;
   $patternx =~ s/\\\)/\xff/gs;

   while ($patternx =~ s/(.*?\|)// && (--$x) > 0) {
      $segment = $1;
      $xxx = $segment;
      $fpat .= (" " x $offset) . $segment . "\n";
      if ($u = $xxx =~ s/\(//g) {
        $offset += 3 * $u;
      }
      if ($v = $xxx =~ s/\)//g) {
        $offset -= 3 * $v;
      }
#print "----   $segment   $u $v   $offset\n";
   }
   $more = $x > 0 ? "" : " more...";
   $fpat .= (" " x $offset) . $patternx . $more . "\n";
   $fpat =~ s/\xfe/\\(/gs;
   $fpat =~ s/\xff/\\)/gs;
#print "----  residue: $patternx        $offset\n";
   $xxx = $patternx;
   $w = $xxx =~ s/\)//g;
   $offset -= 3 * $w;
   if ($offset != 4) {
      print "xxxx Final offest not 4: $offset\n";
   }
#print "\n";
   return $fpat;
}

<< titles.pl  L: 70,306. A: 100644. M: 2010-01-29 22:10:04 UTC [=1264803004] -1675.64d <<

[ Please note: ]  Some systems do not provide this script with a return address (the HTTP_REFERER cgi environment variable). In those cases, the "Return" icon at right is disabled, but you can still use your web browser's BACK button to return to the page from which you came to here. I apologize. Thank you for your understanding.

Page generated by:
http://www.users.cloud9.net/~bradmcc/cgi-bin/ascii.pl?f=titles.pl
Copyright © 2001-2005 Brad McCormick, Ed.D.
bradmcc@cloud9.net [ Email me! ]
26 April 2008CE
v10.05
[ ]
[ ]
[ Notice what's hiding in plain sight! ] [ ]
[ ] [ ]
[ Go home! (BMcC website Home page!) ] [ ] [ Use your web browser's BACK button to return to page from which you linked to here! ] [ ]
[ ]
[ Go to Site Map! ] [ ] [ HTML 3.2 Checked! Test me! ] [ ]
[ ]
[ ]
[ Go to website Table of Contents! ] [ ] [ Welcome to my website! Please come in! ]
[ ]
[ ]