#!/usr/local/bin/perl # findpmod.cgi by David Efflandt vuser@cgi-help.virtualave.net # # Form to check if perl module is in the default search path (@INC) # or extra path entered in form. # Last updated 8/14/99 use CGI qw/:standard :netscape/; # Page header with virtualave banner print header, start_html('Perl Module Test'), # "\n",'', "\n"; # View a module if ($file = param('man')) { $file =~ s/[\|\&\*\?;()<>]|\.pm//g; $file =~ s/\/|\\/::/g; # Adjust following path to 'perldoc' on your system $out = `/usr/local/gnu/bin/perldoc $file 2>&1`; $out =~ s//>/g; $out =~ s/.\cH//g; # filter bs enhanced manpages print center(h1($file." manpage")),hr,pre($out),end_html; exit; } # Default title print center(h1('Perl Module Test')), center(h3('See if a module is on this system')),hr,p; # Results of module search if (param()) { $mod = param('module'); $mod =~ s|::|/|; $mod .= '.pm' unless $mod =~ /\.p(l|m)/; foreach $key (@INC) { if (-r "$key/$mod") { # found it if we can read it $lib = $key; if ($mod =~ /\.pm$/) { print center(table( Tr([td(["$mod is in \@INC path: $lib ", ' - ',' '.a({href=>url(relative=>1). "?man=$mod"},$mod." manpage")])]))); last; } else { print center("$mod is in \@INC path: $lib"); } } } if (-r param('xpath')."/$mod") { # found in extra path $lib = param('xpath'); print center("use lib '$lib';"); } print 'Module ',param('module'),' not found' unless $lib; print p,hr; } # @INC (default include) paths and form in table print b("Default Perl Search Paths:"),br; $paths = join br,@INC; print $paths,hr; print start_form,table(Tr([ td([b('Module: '),textfield('module')]), td({colspan=>2},[em('Examples: Text::Wrap, Text/Wrap.pm or find.pl')]), td([b('Extra Search Path:'),textfield('xpath')]), td([submit,reset])])),end_form;