use Path::Tiny qw/ path /; my $outfh = path( "out.html" )->openw_utf8; say $outfh "\x{FEFF}\x{1F42A}\x{1F42B}"; close $outfh; #### use Path::Tiny qw/ path /; path( "out.html" )->spew_utf8( "\x{FEFF}\x{1F42A}\x{1F42B}" );