chomp(): function in Perl is used to remove the last trailing newline from the input string. $txt = "This my text "; Syntax: chomp($txt); #new line will be removed chop(): Chop remove the last character from the string. Syntax: chop($txt); #last char will be removed