Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

chomp

Removes the trailing record separator (default: newline) from each argument. Returns the total number of characters removed.

Respects $/ (input record separator). When $/ is undef (slurp mode), chomp is a no-op. When $/ is "" (paragraph mode), removes all trailing newlines. Handles CRLF line endings — \r\n counts as 2 characters removed.

Synopsis

$count = chomp($var);
$count = chomp(@list);
chomp $var;

See Also

chop, $/