Help for this page

Select Code to Download


  1. or download this
    s/\s*$/\n/s;        # assuming \s will catch your newline
    s/\s*[\r\n]+$/\n/;  # otherwise, this should do it
    
  2. or download this
    substr($_, -2, 2) = undef;   # deletes last 2 characters
    substr($_, -3, 3) = "\n";    # if your string ends in a newline