Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
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;

In reply to [Perl-CGI] Print non-interpolated string by Digioso

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (9)
    As of 2014-08-29 23:05 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (289 votes), past polls