http://qs321.pair.com?node_id=140088

Marcello has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I use the following regexp to remove all unwanted characters (ord 0..31)
my $startCh = chr(0); my $endCh = chr(31); $text =~ s/[$startCh-$endCh]//g;
This works fine, but I want to preserve the newlines (ord 10). Is there any way to specify elements in the regexp which should NOT be included in the specified range?
I know I could do
$startCh = chr(0); $endCh = chr(9); $text =~ s/[$startCh-$endCh]//g; $startCh = chr(11); $endCh = chr(31); $text ==~ s/[$startCh-$endCh]//g;
but then I run into problems when I want to exclude another character.

TIA!