This is a sub I use as part of a man.cgi app, an interface to look up perl docs.
use strict;
use Pod::Simple::Search;
use constant DEBUG => 0;
for (qw(CGI.pm File::PathInfo HTML/Template.pm Smart::Comments)){
my $name = $_;
my $returned = lookup_as_perl($name);
print " ARG: $name = $returned\n";
}
sub lookup_as_perl {
my $arg_name = shift;
print STDERR "lookup_as_perl() $arg_name, " if DEBUG;
$arg_name=~s/^\/+//; # take out leading slashes
$arg_name=~s/\/+/\:\:/g;
$arg_name=~s/\.html$|\.pod$|\.pm$//;
$arg_name=~s/\/+/\:\:/g;
print STDERR "cleaned to $arg_name, " if DEBUG;
#can we find this?
my $search = Pod::Simple::Search->new;
my $result = $search->find($arg_name);
$result ||= 0;
print STDERR "result = $result\n" if DEBUG;
return $result;
}
# returns ...
#[betti@mescaline cgihelp]# perl test.pl
# ARG: CGI.pm = /usr/lib/perl5/5.8.8/CGI.pm
# ARG: File::PathInfo = /usr/lib/perl5/site_perl/5.8.8/File/PathInfo.p
+m
# ARG: CGI::Carp = /usr/lib/perl5/5.8.8/CGI/Carp.pm
# ARG: Smart::Comments = /usr/lib/perl5/site_perl/5.8.8/Smart/Comments
+.pm
# ARG: HTML/Template.pm = /usr/lib/perl5/site_perl/5.8.8/HTML/Template
+.pm
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|