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

In order to get it to strip whitespace at the end of the string, you need to put in a non-greedy specifier, like this:
$string =~ s/^\s*(.*?)\s*$/$1/;
That said, though, it's better to just do this in two steps, as others have shown.
  • Comment on RE: How do I remove whitespace at the beginning or end of my string?
  • Download Code