Formats and end of line characters
Is开发者_如何学Python there any way to change the end of line character for a perl format?
I need to output a file in DOS format and it looks like write does not obey what is in the $\ variable.
I'm assuming you are trying to do this on a non-Windows platform?
You just need a :crlf layer on your filehandle, e.g.:
open FOO, "> :crlf", "foo.txt" or die "error: $!";
format FOO=
hi
there
.
write FOO;
You can apply layers to existing filehandles using binmode:
binmode STDOUT, ":crlf";
精彩评论