#!/usr/bin/perl # # Creates a .xhtml compliant index.html file # my $infile = shift @ARGV; map { s/\.[0-9]$//; $pages{$_} = 1; } @ARGV; open(I,$infile); $first = 1; print '

Man pages

'; while () { if (/^#\s*(.*)/) { print "\n" if (!$first); print "

$1

\n"; print "\n"; $first = 0; } else { my $name = $_; my $title; chomp($name); if (!exists($pages{$name})) { print STDERR "$name is in $infile, but not in the rest of the args.\n"; } open(H,"$name.html"); while () { if (/

(.*?)<\/h1>/i) { $title = $1; } if (/

NAME<\/h2>(.*)/i) { $_ = $1; # Ignore blank lines while (/^\s*$/) { $_ = ; } $title = $_; chomp($title); $title =~ s/\s*$name\s*-\s*//; # Remove any complete <> tags $title =~ s/<.*>//i; # Remove any half open tags $title =~ s/<.*//i; } } close(H); print "

\n"; print " \n"; print " \n"; print " \n"; print "\n"; delete $pages{$name}; } } print '
$name$title

'; @left = keys(%pages); if ($#left > -1) { print STDERR "missing a filing location for: ", join(", ", @left), "\n"; }