开发者

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";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜