Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Etymology of chomp?

by Anonymous Monk
on Feb 26, 2012 at 10:40 UTC ( #956246=note: print w/ replies, xml ) Need Help??


in reply to Etymology of chomp?

In a linux terminal, in a far away decade, ye olde larry cat some dos.txt before he dos2unix, so he saw some ^M at the end of line, and larry thought , it is common to need to chop these, but chop already chops , eurkea! chomp


Comment on Re: Etymology of chomp?
Re^2: Etymology of chomp?
by chacham (Curate) on Feb 26, 2012 at 13:01 UTC
    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

    .
      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.

Re^2: Etymology of chomp?
by JavaFan (Canon) on Feb 26, 2012 at 13:35 UTC
    chomp removes newlines. Which, if $/ isn't set, is ^J, not ^M, which will be left alone by chomp.

      Are you making fun of me?

Re^2: Etymology of chomp?
by aufflick (Deacon) on Feb 27, 2012 at 05:29 UTC

    I know Larry visits Australia from time to time, and he probably ate what is possibly the best flavour to dollar ratio chocolate bar in the world, the Cadbury Chomp.

    Chomp_(chocolate_bar)

    I assume he named the chomp operator in honour.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (16)
As of 2014-08-29 16:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (282 votes), past polls