#!/usr/bin/perl -w use strict; use URI::Escape; chdir '/tmp'; # if possible my $name = (split '/', $ENV{SCRIPT_NAME} || $0)[-1]; print "Content-type: text/html\n\n"; uri_unescape($ENV{QUERY_STRING} || 'perldoc') =~ /^([\w\s:-]*)$/ or do { print "bad query string: $ENV{QUERY_STRING}"; exit; }; open DOC, "perldoc -u $1|pod2html --header --title='$1'|" or do { print "can't run perldoc: $!"; exit; }; while () { s{ href="/([^."]+)\.html } { local $_ = $1; s|/|::|g; qq(href="$name?$_) }gexi; print; }