in reply to preserving html in patterns

A lot of times it appears that the only way to solve a problem is in one direction, but most of the time, there is another way. Instead of trying to substitute some set of characters, say X, match the negation of X:
use strict; my $line = '$x += 2; $y = $x**2'; $line =~ s/([^\sa-zA-Z0-9])/'&#'.ord($1).';'/ge; # or if you don't want to encode underscores $line =~ s/([^\s\w])/'&#'.ord($1).';'/ge; print "$line\n";
This does not encode newlines and carriage returns, only spaces. Why you would want to use 
 or 
 i don't know, but you can use this to achieve that without encoding spaces:
s/([^ a-zA-Z0-9])/'&#'.ord($1).';'/ge # a single, literal space

I also wonder if this tool is available in the CPAN somwhere. But i digress...

(updated node: got confused about \s and such, sorry)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
F--F--F--F--F--F--F--F--
(the triplet paradiddle)