Heya Monks,
this may be just a stupid question but I couldn't find any solution for it so far...
Basically I have a HTML form with a textarea you can copy anything you like into.
The text is transferred via post method and then I want it to be displayed.
So far so easy... But now I copy for example something like a whole Perl Script into the textarea. After clicking on submit Perl now starts to execute the contents of the textarea. My question is: How can I just display the text without Perl trying to execute it?
Basically... how did they do it on this very website here with the \<code\> tags?
Just try using the sample script and copy the source code of the sample script into the textarea field in your browser.
Sample script:
#!/usr/bin/perl -w
use warnings;
use strict;
use CGI;
use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
my $cgi = CGI->new();
print $cgi->header, # create the HTTP header
$cgi->start_html(-title=>"Test",
-author=>'webmaster at digioso.org');
if($ENV{'REQUEST_METHOD'} eq 'GET')
{
print qq{<form action = "textareatest.pl" name = "form" method = "
+post">
<textarea name = "text" cols = "50" rows = "10"></text
+area><br/>
<input type = "submit"/>
</form>};
}
elsif($ENV{'REQUEST_METHOD'} eq 'POST')
{
my $text = $cgi->param('text');
print qq{$text<br/>};
}
else
{
print "Unknown request method!<br/>";
}
print "</body></html>";
exit 0;
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.