Is there a way to do this in one line?
$x =~ s/^\\s+//; $x =~ s/\\s+$//;
In other words, remove all leading and trailing whitespace from a stri
Here you go: $x =~ s/\A\s*(.*?)\s*\z/$1/;
$x =~ s/\A\s*(.*?)\s*\z/$1/;