http://www.perlmonks.org?node_id=1031321


in reply to Re^2: Relationship between chomp() operator and STDIN
in thread Relationship between Chomp() operator and STDIN

A scalar variable can hold just about any reasonable value, and is not inherently newline terminated. However, when input comes from a file or keyboard, the newline is often the "record separator", and as such will be included in the input.

Note, other record separators are also possible for files, and legal, though not as ubiquitous. perlvar mentions that $/ is used to set the input record separator for the currently selected input filehandle. If an input file contained records delimited by | (pipe character), you could set local $/='|';, for example, and in that case, chomp would chomp trailing | characters instead of trailing newlines.


Dave

Replies are listed 'Best First'.
Re^4: Relationship between chomp() operator and STDIN
by tty1x (Novice) on Apr 30, 2013 at 06:17 UTC
    Ahh thanks for the reply. The 'record separator' concept is new to me and it solved the question :)