You are outputting the text as you receive it.

This is how HTML works. HTML knows nothing about normal linebreaks. Whitespace in text does not break lines in HTML.

If you want to output paragraphs from your text in HTML, you need to convert all linebreaks to <br> tags, or wrap paragraphs in <p>...</p> pairs, or output the text in <pre> tags. Here is how to add <br> tags:

my $textarea_content = $q->param('message'); # Escape all characters that are special for HTML my %html_escape = ( '<' => '&lt;', '>' => '&gt;', '&' => '&amp;', ); $textarea_content =~ s/([<>&])/$html_escape{ $1 }/ge; # Convert newlines to <br> tags $textarea_content =~ s/\r?\n/<br>\n/g; print $textarea_content;

In reply to Re: Retrieve and Print TextArea Content by Corion
in thread Retrieve and Print TextArea Content by Milti

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.