bart is right -- this is a cleaner, safer way:
#!/usr/bin/perl -w
use warnings;
use strict;
binmode(STDIN,":utf8");
binmode(STDOUT,":utf8");
while(<>)
{
# if you just want to get rid of non-breaking spaces, do this:
tr/\xA0/ /;
# if you really want to change every kind of whitespace and every stri
+ng
# of two or more whitespace to a single space, do this instead:
s/\s+/ /g; # in utf8 strings, \s matches non-breaking space
s/ $/\n/; # (puts back the \n at the end of the line)
print;
}
(updated to remove incorrect use of "g" modifier on tr///)