Are you sure that you're not seeing "bad characters" because you're interpreting the file with the incorrect encoding? For instance, the text file may be encoded in UTF-8, but you're reading it as ISO-8859-1.
You may want to give Encode::Guess a try, to figure out what encoding it is.