Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^3: Relationship between chomp() operator and STDIN

by davido (Cardinal)
on Apr 30, 2013 at 05:16 UTC ( #1031321=note: print w/replies, xml ) Need Help??

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.


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 :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031321]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2020-10-25 11:21 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (249 votes). Check out past polls.