Click to See Complete Forum and Search --> : \What c\harac\ters nee\d to be esca\ped\?
dominicanpapi82
09-03-2006, 03:02 AM
I've been searching all over the place to see which characters need to be escaped. I know that in order to print text with the characters @#$%&"'\, that I have to escape them by typing \@\#\$\%\&\"\'\\. I also found a list of the text that can be escaped, like \n,\r,\Q ... \E, etc. but I can't find a full list of non-alphabet characters that need to be escaped.
Charles
09-03-2006, 05:47 AM
See http://perldoc.perl.org/perlop.html#Quote-and-Quote-like-Operators-operator%2c-quote-operator%2c-quote-like-q-qq-qx-qw-m--qr-s-tr-'-''-%22-%22%22-%2f%2f-%60-%60%60-%3c%3c-escape-sequence-escape .
Nedals
09-03-2006, 01:03 PM
... I know that in order to print text with the characters @#$%&"'\, that I have to escape them by typing \@\#\$\%\&\"\'\\. Not quite true if you really mean 'print....'
If you put your print statement in 'single' quotes, then the only chars that need to be escaped are.... any nested 'single' quotes and the escape char '\'.
print 'CHARS: @#$%&"/ \' \\' ."\n";
dominicanpapi82
09-03-2006, 02:03 PM
Not quite true if you really mean 'print....'
If you put your print statement in 'single' quotes, then the only chars that need to be escaped are.... any nested 'single' quotes and the escape char '\'.
print 'CHARS: @#$%&"/ \' \\' ."\n";
What if I plan on putting everything in double quotes?
If I do the following:
print <<EndMARKER;
line1
line2
line3
etc
EndMARKER
What characters do I have to escape then?
Charles
09-03-2006, 02:16 PM
See http://perldoc.perl.org/perlop.html#Quote-and-Quote-like-Operators-operator%2c-quote-operator%2c-quote-like-q-qq-qx-qw-m--qr-s-tr-'-''-%22-%22%22-%2f%2f-%60-%60%60-%3c%3c-escape-sequence-escape. It's all spelled out there and it's too complicated to just use a list.