use Encode qw( encode ); open(my $fh, '>', $output_fqn) or die; print $fh (encode('UTF-8', $text));