hmerrill has asked for the wisdom of the Perl Monks concerning the following question:
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.http://my.server.com/perldoc.pl?mod=DBI
Seems simple in concept, but it's not working, and I'm guessing that I'm missing something simple. Here's the code:
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.#!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); }
TIA.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI perldoc with pod2htm
by Zaxo (Archbishop) on Jun 14, 2004 at 19:52 UTC | |
|
Re: CGI perldoc with pod2htm
by borisz (Canon) on Jun 14, 2004 at 18:32 UTC | |
by hmerrill (Friar) on Jun 14, 2004 at 19:07 UTC | |
by borisz (Canon) on Jun 14, 2004 at 19:21 UTC | |
|
A CGI to read PODS (was Re: CGI perldoc with pod2htm)
by jZed (Prior) on Jun 14, 2004 at 20:39 UTC | |
by spartan (Pilgrim) on Jun 15, 2004 at 19:59 UTC | |
by hmerrill (Friar) on Jun 29, 2004 at 17:18 UTC |