Like
tye said, use a tool to do this, and a good alternative to
CGI.pm is
HTML::Template.
The
<tmpl_var> tag has an option attribute
named
escape that, when set to
html,
will solve this problem in a very painless way for the
coder. Here is a complete CGI script to demonstrate:
#!/usr/bin/perl -T
use strict;
use warnings;
use CGI qw(header param);
use HTML::Template;
my $tmpl = HTML::Template->new(filehandle => \*DATA);
$tmpl->param(html => param('html'));
print header, $tmpl->output;
__DATA__
<html>
<head>
<title>textarea test</title>
</head>
<body>
<form>
<textarea name="html"><tmpl_var name="html" escape="html"></textarea>
<input type="submit" />
</form>
<hr />
<p><tmpl_var name="html"></p>
</body>
</html>
Be sure and view the source and inspect the contents of
the textarea element.
jeffa
L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.