use File::BOM; open RET,'>:via(File::BOM)',$filename ; #print RET "print BOM"; close RET;