HTH.chomp VARIABLE chomp( LIST ) chomp This safer version of "chop" removes any trailing strin +g that corresponds to the current value of $/ (also known as $INPUT_RECORD_SEPARATOR in the "English" module). It r +eturns the total number of characters removed from all its arg +uments. It’s often used to remove the newline from the end of a +n input record when you’re worried that the final record may be + missing its newline. When in paragraph mode ("$/ = """), it re +moves all trailing newlines from the string. When in slurp m +ode ("$/ = undef") or fixed-length record mode ($/ is a referenc +e to an integer or the like, see perlvar) chomp() won’t remove +any- thing. If VARIABLE is omitted, it chomps $_. Example: while (<>) { chomp; # avoid \n on last field @array = split(/:/); # ... }
In reply to Re: Re: How do I capture the last character in a string?
by hmerrill
in thread How do I capture the last character in a string?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |