Update: Exchange <pre>s for <code>s...#!/perl/bin/perl # # SiteMap.pl -- create a .html sitemap from a .chm .hhc file. use strict; use warnings; use diagnostics; use HTML::TokeParser::Simple; my $p = HTML::TokeParser::Simple->new($ARGV[0]); my $indent = 0; print "<!doctype html public \"-//W3C//DTD HTML 4.0 Transitional//EN\" +>\n"; print "<html>\n"; print "<head>\n"; print "<title>$ARGV[0]</title>\n"; print "</head>\n"; print "<body>\n"; print "<h2>Sitemap for $ARGV[0]</h2>\n"; while (my $token = $p->get_token) { if ($token->is_start_tag('ul')) { myprint($indent,"<ul>\n"); $indent++; } elsif ($token->is_start_tag('li')) { myprint($indent,"<li>"); } elsif ($token->is_end_tag('ul')) { $indent--; myprint($indent,"</ul>\n"); } elsif ($token->is_start_tag('param')) { my $ref = $token->return_attr(); if ($$ref{'name'} eq 'Name') { myprint(0,$$ref{'value'} . "</li>\n"); } } } print "</body>\n"; print "</html>\n"; sub myprint { my $l = shift; my $s = shift; my $pad = ' ' x $l; print "$pad$s"; }
--hsm
"Never try to teach a pig to sing...it wastes your time and it annoys the pig."
|
|---|