Rather than cutting out unwanted characters, you may want to only match what you know to be ok for the entire line. For example, if you want only printable non-whitespace characters, then match only that (see "perldoc perlre" for more details). Also, you may want to warn/die if you find characters in a line that you don't think should be there.
In reply to Re^3: When is a trailing space not a trailing space?
by bluto
in thread When is a trailing space not a trailing space?
by markguy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |