When to use chomp?

VAR121 picture VAR121 · Sep 27, 2012 · Viewed 29.4k times · Source

What is the purpose and advantages of chomp function. What all can it do? Does using chomp creates any problems? or using chomp after file opening is necessary?

Answer

Chankey Pathak picture Chankey Pathak · Sep 27, 2012

chomp is used to remove the $/ variable which is set to mostly \n (new line).

$/ is the input record separator, newline by default.

chomp: It returns the total number of characters removed from all its arguments. It's often used to remove the newline from the end of an input record.