http://www.perlmonks.org?node_id=164839


in reply to How do I remove control characters?

Try perldoc perlop and look for the transliteration operator.

tr/\040-\176/ /c;
The 'c' option means complement the range.
Note: you may have to binmode the filehandle, depending on your OS.