Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-25 22:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found