There are many ways to do what you describe; you need to decide exactly what it is that you *want*.

If you want the text to show up verbatim but subject to all of HTML's vagaries (like collapsing whitespace) and render angle brackets as angle brackets, you should proabably entify (entityfy?) the text. Look for HTML entity encoding.

If you want to put the text reasonably formatted, use a module that will at the very least insert <p> or <br> tags as appropriate for line breaks.

If you want to allow some HTML markup, like font tags, breaks, rules, etc., but not all, look at a tag filter or scrubber.

For all of this, keep in mind that if you reasonably expect it to contain utf8 non-ascii characters, you'll want to make sure to let perl know about that by using decode_utf8 or similar function to tag the scalar, so that it doesn't get oddly transcoded (vagueness intentional: I am not an expert on this and it's a very different process from perl 5 to 5.6 to 5.8; your mileage will vary).


In reply to Re: Scalar string to web page by rlucas
in thread Scalar string to web page by tomazos

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.