title: Is there a Perl-compatible regular expression to trim whitespace from both sides of a string?
body: <p>Is there a way to do this in one line?</p>
  
  <pre><code>$x =~ s/^\s+//;
  $x =~ s/\s+$//;
  </code></pre>
  
  <p>In other words, remove all leading and trailing whitespace from a string.</p>