hello all,

a few days ago I was doing some data munging on the perlfaq manpages (basically, splitting each page in single faqs and put them in a DB table) and after a while I realized I had the need to convert a snippet of POD (a single faq) to HTML.

I promptly typed use Pod::Html; but suddenly I felt something was wrong. what I wanted was something like:

my $html_snippet = pod2html($pod_snippet);
but Pod::Html seems to be nothing more than a backend for the (totally fine) pod2html script. Thus, it only accepts input from a file (or STDIN) and writes to a file (or STDOUT). gack.

for my application, which is a CGI script, I was absolutely reluctant to spool on the filesystem, and while I can think about redirecting STDOUT to a variable, setting up a fake STDIN for pod2html to read from a variable looks, at the very least, unnecessarily complicated.

after a bit of homework, I found a solution (workaround?) to my problem:

use IO::Scalar; use Pod::Tree::HTML; $html_snippet = ""; $html_snippet_handle = IO::Scalar->new(\$html_snippet); $pod2html = Pod::Tree::HTML->new(\$pod_snippet, $html_snippet_handle); $pod2html->translate;
it works ($html_snippet will contain the pod2htmlized $pod_snippet), but it required the installation of 4 additional modules (let alone syntactic cruft and efficiency concerns), just to make something that Pod::Html could, and should, very easily handle.

so the question is: am I the only one to think that Pod::Html should do far, far much more than it does now? and if it doesn't want to do it, let's kick it out from CPAN! ;-)

cheers,
Aldo

King of Laziness, Wizard of Impatience, Lord of Hubris


In reply to unhappy with Pod::Html by dada

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.