chop always takes off the last character of a string and returns that character.
chomp takes off any and all trailing newlines, but leaves the string alone if there are no newlines. It returns the number of characters removed. $/ determines what chomp thinks is a newline. So you can local that to remove newlines from files from other systems that have different newlines than your native OS.
In reply to Re: When do you use chop instead of comp?
by steves
in thread When do you use chop instead of chomp?
by Jemts
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |