perl - Is it wrong to print $/ instead of \n? -


perl's documentation says $/ is:

the input record separator, newline default. influences perl's idea of "line" is.

so, wrong to:

print stderr $var, $/; 

instead of:

print stderr "$var\n"; 

?

what go wrong if former?

perhaps looking output record separator instead?

perldoc perlvar:

 io::handle->output_record_separator( expr )    $output_record_separator    $ors    $\

the output record separator print operator. if defined, value printed after last of print's arguments. default "undef".

you cannot call "output_record_separator()" on handle, static method. see io::handle.

mnemonic: set "$\" instead of adding "\n" @ end of print. also, it's $/, it's "back" perl.

for example,

$\ = $/; print stderr $var; 

Comments