< Perl Programming < Keywords

The chomp keyword

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

  chomp VARIABLE
  chomp(LIST)
  chomp
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.