in reply to "Wide character in print"

The error has gone away but there are weird characters that are still showing up like this when I print it out:

There are many different ways of representing characters using bytes. These are called "character encodings", or just "encodings" for short.

By using :utf8, you told Perl to encode the characters using UTF-8. (Actually, using a superset of UTF-8 specific to Perl, but that's ok.) However, your viewer appears to be assuming the content of the file is encoded using iso-latin-1 (or something).

Tell your viewer the file is UTF-8, or use the encoding your viewer expects instead of UTF-8. The latter is done using:

binmode OUT, ':encoding(name_of_encoding_here)';

For files encoded using UTF-8, some viewers will react positively to having chr(0xFEFF) as the first character.