Perl 的文档说 $/
是:
The input record separator, newline by default. This influences Perl's idea of what a "line" is.
那么,基本上是错误的:
print STDERR $var, $/;
代替:
print STDERR "$var\n";
?
如果我做前者会出什么问题?
最佳答案
也许您正在寻找输出记录分隔符?
IO::Handle->output_record_separator( EXPR ) $OUTPUT_RECORD_SEPARATOR $ORS $\The output record separator for the print operator. If defined, this value is printed after the last of print's arguments. Default is "undef".
You cannot call "output_record_separator()" on a handle, only as a static method. See IO::Handle.
Mnemonic: you set "
$\
" instead of adding "\n
" at the end of the print. Also, it's just like$/
, but it's what you get "back" from Perl.
例如,
$\ = $/;
print STDERR $var;
关于perl - 打印 $/而不是\n 是错误的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31388841/