use utf8; ... ... open (OUT,">:utf8", "$name") or die "cannot open file for writing"; ... print OUT $_;