do
s[\\][\\\\]g followed by
s['][\']g on the input string, then use single quotes to delimit it in your print statement.
The first substitution escapes the escape character, and the second escapes the single quote character. As these are the only two things that have special signifigance in a single quoted string, the script will print out exactly what they put in.
ObSecurityWarning: If the text input by user A will be seen over the web by user B, you almost certainly want to strip out some or all html tags, or someone could insert something like
<p onmouseover="location.refresh('http://www.goatse.cx')">Blah blah blah</p>
or worse. (Though I don't know much that's worse than having to look at the goatse.cx picture.) There are CPAN modules to do this, I believe.
--
Ryan Koppenhaver, Aspiring Perl Hacker
"I ask for so little. Just fear me, love me, do as I say and I will be your slave."
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.