in reply to Excluding non ascii characters

Here's a solution that works with arbitrary encodings rather than just ASCII:
use Encode qw( decode encode ); my $input = '...'; my $enc = 'US-ASCII'; my $spc = encode($enc, ' '); my $filtered = decode($enc, encode($enc, $s, sub { $spc }));

Encode