#!/usr/bin/perl # perldoc.cgi by David Efflandt tech-ph@de-srv.com # last updated 3/11/00 # # View perldocs from web browser. # Required module use CGI::Carp qw(fatalsToBrowser); use CGI qw/:standard :netscape/; $ENV{PATH} .= ':/bin:/usr/bin:/usr/local/bin:/usr/contrib/bin:/usr/local/contrib/bin'; # Page header and input field $file = param('doc').' ' if param('doc'); if ($file =~ s/[\/\\\|\&\*\?;()<>`]//g) { $title = "Invalid command: $file"; $file = ''; } elsif ($file) { $title = "$file perldoc"; } else { $title = "Perl Docs"; } print header, start_html($title),"\n", center(h1($title)),start_form,center('perldoc ',textfield('doc'),' ', submit(undef,' Read ')),end_form; if ($file) { print "Looking up 'perldoc $file'",p; $out = `perldoc -t $file 2>&1`; $out =~ s//$gt;/g; $out =~ s/.\cH//g; # filter bs enhanced manpages print hr,pre($out); if (length($out) > 255) { print hr,start_form,center('man ',textfield('doc'),' ', submit(undef,' Read ')),end_form; } } else { print hr,'To read perldoc pages about a perl command, enter the ', 'command in the input field. For example if you enter ',b('perl'), " you can read 'perldoc perl'. ",b('Note: ')," or if you enter a ", "module name like CGI::Carp you can read docs about the module.", "words are case sensitive. The word 'cgi' is not the same as 'CGI' ", "(man pages about CGI.pm module).",p, 'Some switches are useful:',br, '-f followed by a function defines the function ', '- Example: ',em('-f localtime'),br, '-q followed by quoted string will try to find that ', 'in perlfaq - Example: ',em('-q "what modules"'),br, '-h for help on other perldoc switches.'; } print end_html;