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.


In reply to CGI perldoc with pod2htm by hmerrill

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.