http://www.perlmonks.org?node_id=8244


in reply to How do I remove whitespace at the beginning or end of my string?

One line is just as good.
#replace 0 or more whitespaces at the beginning # or 0 or more whitespaces at the end # with nothing $string =~ s/^\s+|\s+$//g;
Credit to perlmonkey for corrections to original post -- Ed.
  • Comment on Re: How do I remove whitespace at the beginning or end of my string?
  • Download Code