#!/usr/bin/perl -w

$start = shift || '.';

open(FIND, "find $start -name index.html -print |") or die $!;

while (<FIND>) {
    chomp;
    ($dir = $file = $_) =~ s#/[^/]*$##;

    local @ARGV = $file;
    local $^I = ".prehack";
    local $/ = "<LI>";
    while (<>) {
	if ( m#<A\s+HREF="([^/.][^"]+)">.*?</a>\s*(?=by\b|from\b)#gi ) {
	    $man = "$dir/$1.html";
	    if (-e $man) {
		print STDERR "$man\n";
		$man =~ s#.*/##;
		s#\G#and its <A HREF="$man">manpage</A> #;
	    }
	} 
    } continue {
	print;
    } 

} 
