Perl does seamlessly convert \r\n to \n on Windows unless you binmode. It would be nice if there was a layer that handled common line endings seamlessly, but noone's gotten around to doing it. It's not that hard, even. | [reply] |
::via is not relevant if the module is already written. It's also missing some key functionality relating to buffering, so I recommend writing layers in XS instead.
Thanks for pointing out :eol, though. This had come up recently on p5p, and noone mentioned it was already written.
It's quite unfortunate that it requires a different configuration for input handles than for output handles. It prevents its use as a default layer.
| [reply] |
I still don't quite understand why perl doesn't seemlessly translate \r\n to a \n.
Presumably, the perl that codepad.org is running is a Unix-built perl, which means it does not add a :crlf PerlIO layer to file handles by default (as is done on Windows). The :crlf layer is responsible for transparent \r\n <—> \n linefeed translations (see PerlIO).
Adding binmode DATA, ":crlf" before slurping in the data should emulate Windows perl behavior on codepad.org.
| [reply] [d/l] [select] |