chomp#

Synopsis#

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

Description#

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.

See also#

chop, $/