s/\s*$//; # means substitute zero or more spaces # before end-of-line with NOTHING (get rid of them) #### $jo = "Mary had a little lamb "; print $jo . "blah\n"; $jo =~ s/\s*$//; # get rid of the spaces print $jo . "blah\n"; #### Mary had a little lamb blah # spaces at end of $jo Mary had a little lambblah # spaces be gone! #### s/\s*$//gm;