|The stupid question is the question not asked|
chop() and chomp()by Parham (Friar)
|on Jan 01, 2002 at 04:23 UTC||Need Help??|
documentation provided for the functions:
This is an alternative to the chop() function. It removes characters at the end of strings corresponding to the $INPUT_LINE_SEPARATOR ($/). It returns the number of characters removed. It can be given a list of strings upon which to perform this operation. When given no arguments, the operation is performed on $_.
This function removes the last character of a string and returns that character. If given a list of arguments, the operation is performed on each one and the last character chopped is returned.
these two functions are very much alike... they both remove one (or more) characters from the end of a string... So how are they different you ask? Chomp() ONLY removes new line characters (these are specified in $/), whereas Chop() removes anything that is at the end of the string (it really doesn't care what it is)...
let's demonstrate these two functions:
remember.. this with a little bit of usefulness chop() can be the same as chomp()
most of the time, you'll want to chomp(), but you might want to use chop() with regexes for the same output