[thelist] What characters to 'escape' Perl?

Anthony Baratta Anthony at Baratta.com
Mon Feb 24 22:17:01 CST 2003


At 07:46 PM 2/24/2003, Hugh Blair wrote:

>My lack of Perl is showing. What characters need to be 'escaped'
>in the following type of statements? (This Is not complete, just
>representitive of the lines in this routine)
>
>I thought all of these   " @ % $    were the only ones,
>but something is still failing and I can't find it.
>Also, is there any rules when these characters should *not*
>be escaped in the type of statements listed above?

First off, using ' mean literal. You shouldn't have to escape anything
except another '. Using " means you need to escape reserved characters like
@,$,%, and of course ".

If you are really stringing together print statements like that, I prefer
this method:

print qq[Content-type: text/html

<html>
<head><title>Recommend</title></head>
<body bgcolor="$BodyColor">

<td width="33%" align="middle">
<td width="100" bgcolor="$TableColor">
     <font face="Arial,Helvetica" color="$TableFont">To:</font>
</td>
<!-- Copyright 1999-2002 -->
</body>
</html>
];

As long as you don't use [] in your text.
---
Anthony Baratta
President
Keyboard Jockeys

"Conformity is the refuge of the unimaginative."




More information about the thelist mailing list