Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Etymology of chomp?

by chacham (Curate)
on Feb 26, 2012 at 13:01 UTC ( #956255=note: print w/ replies, xml ) Need Help??


in reply to Re: Etymology of chomp?
in thread Etymology of chomp?

To be clear.

Programing Perl describes chomp as "This function (normally) deletes a trailing newline from the end of a string contained in a variable. This is a slightly safer version of chop"

chop itself is "This function chops off the last character of a string variable and returns the character chopped."

IOW, chop does what it means, it chops off the end. chomp is a very similar one, that only (before version 5.6) chops off ^M

.


Comment on Re^2: Etymology of chomp?
Re^3: Etymology of chomp?
by JavaFan (Canon) on Feb 26, 2012 at 13:34 UTC
    Actually, chomp, by default, removes a newline. Which is actually ^J, not ^M. ^M is a carriage return, and will be left alone by chomp (unless $/ is set to something that contains it).
      Actually, chomp, by default, removes a newline. Which is actually ^J, not ^M. ^M is a carriage return

      Excellent point. But chojp doesn't sound like Larry's native tongue. And there that little known factual fauxism that Larry originally wrote perl for the typewriter.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2014-09-02 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (31 votes), past polls