Chop and chomp in perl

16th September 2008 11:23, Public, Comments:0, Tags: none

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 = "abcdef\n";
chomp($string) # $string is now abcdef

Comment on this..



(will not be published)
(optional)
(to try and keep spammers away)

Elsewhere