in reply to CR-LF Newlines as 2 distinct characters
It tried using binmode to see if I could get the :crlf layer to be applied before the encoding layer, but it doesn't work. This seems like something that should be fixed in perl, since Windows is the most commonly used OS in the world, after all.
Anyway, here's how I would do it:
You can actually combine the binmode options into the open statement like so:open PLAYLIST, ">", "playlist.plp" or die "Couldn't open playlist.plp: $!\n"; binmode PLAYLIST, ":raw:encoding(utf16le)" or die "binmode: $!\n"; print PLAYLIST "abcd\r\n"; $\ = "\r\n"; print PLAYLIST "efgh";
open PLAYLIST, ">:raw:encoding(utf16le)", "playlist.plp" or die "Couldn't open playlist.plp: $!\n"; print PLAYLIST "abcd\r\n"; $\ = "\r\n"; print PLAYLIST "efgh";
|
|---|