How do I strip blank space from the beginning/end of a string?

The simplest approach, albeit not the fastest, is probably like this:

    $string =~ s/^\s*(.*?)\s*$/$1/;

It would be faster to do this in two steps:

    $string =~ s/^\s+//;
    $string =~ s/\s+$//;

Or more nicely written as:

    for ($string) {
	s/^\s+//;
	s/\s+$//;
    }