in reply to Wide character in print at

Files can only contain bytes, but you're printing something that's obviously not a byte.

You need to convert the text to bytes ("encode" it), or tell Perl to do it for you.

open(my $fh, '>:encoding(UTF-8)', $qfn) or die("Can't create output file \"$qfn\": $!\n"); print $fh $text;