open(my $fh, '>:encoding(UTF-8)', ...) or die ...; sysrwite($fh, $text); # Or: print $fh $text;