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