#!/usr/bin/perl # # read each line from each HTML file on command-line # looking for table of contents. print only the ToC # with substitutions for an external outline jump table. $intoc = 0; $title = ""; while (<>) { if ($intoc) { s/:o) { $intoc = 0; } } else { if (/^

([^<]*)Table of Contents/o) { print "\n

$title

\n"; $intoc = 1; $title = ""; } } }