Chop and chomp in perl

16 September 2008

Just a reminder, so I remember the difference! - chomp is a safer version of “chop” removes any trailing string that matches what perl thinks is a new line)

` $string = “abcdef”;
chop($string) # $s is now f, $string is now abcde
chomp($string) # $string is still now abcde

$string = “abcdefn”;
chomp($string) # $string is now abcdef
`