The chomp function is a safer version of chop
chomp VARIABLE
chomp LIST
chomp
chomp removes any line ending that corresponds to the current value of $/.
$/ is the special Perl variable holding the input record separator.
$/ is defaulting to a newline.
chomp function returns the total number of characters removed.
chomp is usually used to remove the newline from the end of an input record.
If VARIABLE is omitted, it chomps $_.
while (<>) {
chomp;
print;
}
Related examples in the same category