#!/usr/bin/perl -T $ENV{PATH} = "/bin:/usr/bin"; print "Content-type:text/html\n\n"; $topic = $ENV{'QUERY_STRING'}; print "Man Page: $topic\n"; print "\n"; # The only allowed topics will be words that are alphanumeric # (a-zA-Z0-9). Dashes and periods are also allowed; spaces are not. # if ($topic =~ /([\w\-\.]+)/) { $topic = $1; } else { &dienice("Bad topic: $topic"); } print "

$topic

\n"; @out = `/usr/bin/man $topic`; # now print pre tags so it's preformatted. print "
\n";

foreach $i (@out) {
    # man pages are formatted with nroff, so we have to remove the 
    # control characters from them with this regexp.
    $i =~ s/.\cH//g;;

    # now print the line
    print $i;
}
print "
\n"; print "\n"; sub dienice { ($errmsg) = @_; print "

Error

\n"; print "$errmsg

\n"; print "\n"; exit; }