Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Retrieve and Print TextArea Content

by Corion (Patriarch)
on Sep 12, 2025 at 18:23 UTC ( [id://11166203]=note: print w/replies, xml ) Need Help??


in reply to Retrieve and Print TextArea Content

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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11166203]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2025-11-17 21:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (72 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.