我想使用saydos换行格式:
say "foo" 应该显示 foo\r\n
我试图重新定义新的行变量,但它不会改变任何东西
local $/="\r\n";
Run Code Online (Sandbox Code Playgroud)
另一个解决方案是手动编写:
print "foo\r\n";
Run Code Online (Sandbox Code Playgroud)
但它不是很方便
不要使用影响所有句柄的全局变量; 使用
open(my $fh, '>:crlf', ...)
Run Code Online (Sandbox Code Playgroud)
要么
binmode($fh, ':crlf')
Run Code Online (Sandbox Code Playgroud)
:crlf默认情况下已在Windows计算机上为您添加,但是在其中指定open或尝试将其添加到已使用它的句柄中binmode也不会有任何损害.
| 归档时间: |
|
| 查看次数: |
102 次 |
| 最近记录: |