open( OUT, ">:encoding(cp1250)", "output.txt" ) or die "output.txt: $!\n"; # assuming $data contains a utf8 string: print OUT $data; # the string gets converted to cp1250 before being written to the file # (no need to "use Encode" in this case)