Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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.


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2019-07-20 17:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?