#!/usr/bin/perl -T use strict ; use warnings ; use CGI qw/:standard/ ; use CGI::Carp qw/fatalsToBrowser/ ; my $pagesimage = '/images/pages.gif' ; delete $ENV{PATH} ; my $command = param('keyword') ; $command =~ s/[^\w:-].*// ; my %sections = ( 1 => '1: User commands', 2 => '2: System calls', 3 => '3: Library functions', 4 => '4: Devices and network interfaces', 5 => '5: File formats', 6 => '6: Games and demos', 7 => '7: Environments, tables, and troff macros', 8 => '8: Maintenance commands', n => 'n: Tcl/Tk' ) ; my $keywordfield = textfield('keyword','') ; my $sectionmenu = popup_menu( 'section', ['',1,2,3,4,5,6,7,8,'n'], 0, { '','All sections', %sections } ) ; print header()," whatis/apropos $command

UNIX ON-LINE Man Pages


Type a keyword here: $keywordfield

List only section: $sectionmenu

" ; if ($command and $command =~ /([\w.-]+)/) { $command = $1 ; if (open WHATIS, '-|', "/usr/bin/whatis $command" ) { print "whatis $command
\n
" ;
        while () {
	    $_ = linkline($_) || next ;
    	    #s/$/
/ ; print ; } print "
" ; close WHATIS ; } if (open APROPOS, '-|', "/usr/bin/apropos $command") { print "

apropos $command
\n
" ;
	while () {
	    $_ = linkline($_) || next ;
    	    #s/$/
/ ; print ; } print "
" ; close APROPOS ; } } print < © 2002 apropos-cgi 0.6, Christoffer Hammarström. Inspired by man-cgi by Panagiotis Christias. END sub linkline { local $_ = shift ; if (m¤^([-\w:+./()*, ]+)(?$label ! ; s!([-\w:+.]+)\s*\(([n1-8]\w*)\)!$1 ($2)!g ; s!([a-z]{3,}://[^\s\!]+)!$1!g ; s!^((.*?)(.*?)) - !my $str = "$2$3"; $1.' 'x(length $str < 60 ? 60-length $str : 0)!e ; } return $_ ; }