I'm attempting to create my own 'perldoc' cgi script. My plan is to be able to type in a URL like this:
http://my.server.com/perldoc.pl?mod=DBI
and have my CGI script search the @INC array for DBI.pm or DBI.pod - when it finds one it would invoke 'pod2html /path/to/DBI.pm' and spew the output to the browser.
Seems simple in concept, but it's not working, and I'm guessing that I'm missing something simple. Here's the code:
#!C:\Perl\bin
use strict;
use CGI;
my $q = new CGI;
my $module = $q->param('mod');
if (not defined($module)) {
print <<END_HTML;
Content-type: text/html
<html>
<head><title>Perldoc - No module specified!!</title></head>
<body>
<br><br>
<p><center>Perldoc Error - <b>No</b> module specified!!</c
+enter>
</body>
</html>
END_HTML
exit(1);
}
#################################################################
my $found = 0;
my $abs_filename = "";
foreach my $dir (@INC) {
opendir(DH, $dir) or die "Can't open $dir: $!";
while( defined (my $file = readdir DH) ) {
if ($file =~ /$module\.(pm|pod)/) {
$abs_filename = "$dir/$file";
$found = 1;
last;
}
}
}
if ($found) {
#print $q->header('text/html'), $q->start_html("test");
#print $q->header('text/html');
#print $q->h1(`pod2html $abs_filename`);
print "Content-type: text/html\n\n";
`pod2html $abs_filename`;
#print `pod2html CGI`;
#print $q->header('text/html'), $q->start_html("test");
#print $q->h1("\$abs_filename=[$abs_filename]");
#print $q->end_html;
exit 0;
}
else {
print <<END_HTML;
Content-type: text/html
<html>
<head><title>Perldoc - Module $module *NOT* found!!</title></h
+ead>
<body>
<br><br>
<p><center>Perldoc Error - module <b>$module</b> *NOT* fou
+nd!!</center>
</body>
</html>
END_HTML
exit(1);
}
Note that this is on Windows XP. When I run this with "http://my.server.com/perldoc.pl?mod=DBI", a *blank* page is displayed - no error, no nothing. Any ideas would be appreciated.
TIA.