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

Re: When do you use chop insetad of comp?

by webadept (Pilgrim)
on Mar 02, 2002 at 20:09 UTC ( [id://148879]=note: print w/replies, xml ) Need Help??


in reply to When do you use chop instead of chomp?

Chop removes the last character, no matter what it is, EOL, or what ever. Chomp only removes EOL marks if there is one. If not, it does nothing.

The EOL mark Chomp removes corresponds to the current value of $/, so you may want to check that as well on your system.

Chomp also returns the total number of characters removed so you get a 1 or a 0 responce. Chop returns nothing.

webadetp.net

Replies are listed 'Best First'.
Re: Re: When do you use chop insetad of comp?
by maverick (Curate) on Mar 02, 2002 at 20:23 UTC
    minor correction. chop returns the character removed.
    $string = "abc"; print chop $string; # prints 'c' print $string; # prints 'ab'

    /\/\averick
    perl -l -e "eval pack('h*','072796e6470272f2c5f2c5166756279636b672');"

      Ah.. and so it does.. Most usful that. Thanks

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2024-03-28 09:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found