Displays Pod documentation in your web browser

Usage: podder.pl File::Find

Setup: Copy to your /usr/bin directory, then chmod a=rx /usr/bin/podder.pl

#!/usr/bin/perl use Pod::Find qw(pod_where); my $pod = pod_where( { -inc => 1 }, $ARGV[0] ); `pod2html --infile=$pod --outfile=/tmp/pod.html --noindex; konqueror / +tmp/pod2.html`;

Replies are listed 'Best First'.
Re: Display Pod in your web browser
by merlyn (Sage) on Oct 12, 2001 at 11:30 UTC
    • Why the backquotes instead of system?
    • What if the output in $tmp contains shell-significant characters?
    • What if multiple people execute this script at once?
    • My system doesn't have konqueror, but you didn't list that as a dependency. Is there any other means?
    • This is a security hole, because someone else could replace the /tmp-file between creation and use, and force me to execute arbitrary javascript. Ick.

    -- Randal L. Schwartz, Perl hacker

      ouch ouch ouch. Guilty on all counts. In my defence, it's a 2min script to show someone how they could put together something to view their pods in html.

      It all works fine on my system because nobody else uses it. I'll patch it in a few hours to set a better example.

      As for the konqueror dependency, there's no good way to pick up someones browser of choice, since each distribution has a different way of nominating the default browser.

      I might even have a go at patching perldoc to do this properly (tm)

      ____________________
      Jeremy
      I didn't believe in evil until I dated it.

Re: Display Pod in your web browser
by VSarkiss (Monsignor) on Oct 12, 2001 at 16:01 UTC

    How about just wrapping it in a CGI? This works OK on my development box, where I'm the only user (most of the time).

    #! /usr/bin/perl -w use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use Pod::Html; print header('text/html'), start_html('POD browser'), start_form, p('POD: ', textfield('pod'), submit, ), end_form, hr; if (param()) { chdir '/tmp'; # write cache files in /tmp my $pod = param('pod'); my $file = qx(perldoc -l $pod); pod2html $file; } print end_html;
    Yeah, it's slow, but it's convenient. Also, it'd be nice to able to select a directory for the cache files in pod2html. I didn't see a way to do that -- did I miss it?

Re: Display Pod in your web browser
by mexnix (Pilgrim) on Oct 12, 2001 at 23:42 UTC
    I have Winders here at work, so I can't test the code (and I'll feel stupid this already implements this functionalilty). Konqueror (the version that comes with KDEv2.1+ for sure) has the ability to view man pages in HTML by typing #manpage_name in the location bar. It works with most Perl manpages (i.e. #perlop, #File::Find, etc) that I have found.

    __________________________________________________

    s mmgfbs nf, nfyojy m,tr yb-zya-zy,s zfzphz,print;
    - thanks japhy :)

    mexnix.perlmonk.org