Try this,
$str =~ s/[^!-~\s]//g;
In the above, !-~ is a range which matches all characters between ! and ~. The range is set between ! and ~ because these are the first and last characters in the ASCII table (Alt+033 for ! and Alt+126 for ~ in Windows). As this range does not include whitespace, \s is separately included. \t simply represents a tab character. \s is similar to \t but the metacharacter \s is a shorthand for a whole character class that matches any whitespace character. This includes space, tab, newline and carriage return.
Or simply, $str !~ s/[^[:ascii:]]//g;
In reply to Re: Removing Non-Ascii chars from text file
by rsriram
in thread Removing Non-Ascii chars from text file
by MonkPaul
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |