#!/usr/local/bin/perl # findpmod.cgi by David Efflandt tech-ph.de-srv.com # # Form to check if perl module is in the default search path (@INC) # or extra path entered in form. # Last updated 6/20/00 my ($file,$out,$mod,$lib,$key); use CGI::Carp qw(fatalsToBrowser); use CGI qw/:standard :netscape/; print header, start_html('Perl Module Test'),"\n"; $ENV{PATH} .= ':/bin:/usr/bin:/usr/local/bin:/usr/contrib/bin:/usr/local/contrib/bin'; # View a module if ($file = param('man')) { $file =~ s/[\|\&\*\?;()<>`]|\.pm//g; $file =~ s/\/|\\/::/g; $out = `perldoc $file 2>&1`; # temp test print "Nothing returned by perldoc. Path: $ENV{PATH}",p unless $out; $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;