Perl Programming/Keywords/chomp
Appearance
The chomp keyword
[edit | edit source]chomp is the safer version of chop that removes any trailing strings that corresponds to the current value of $/, which is also known as the $INPUT_RECORD_SEPARATOR in the English module, and returns the total number of characters removed from all arguments. In paragraph mode ($/ = "" ), all trailing newlines from the string are removed. In slurp mode ($/ = undef) or fixed-length record mode ($/ is a reference to an integer or the like) chomp() will not remove anything. If VARIABLE is omitted, it chomps $_. If VARIABLE is a hash, it chomps the values of the hash and not its keys, and resets the each iterator.
Syntax
[edit | edit source] chomp VARIABLE
chomp(LIST)
chomp