I was going to post this to the Snippets section but it probably belongs here.
# Strip leading and trailing whitespace from a string $str = unpack "A*", (split ' ', $str, 1)[0];

Note: this is about 50% slower than the method recommended in perlfaq4.

--
John.

Replies are listed 'Best First'.
Re: Strip leading and trailing whitespace from a string.
by Kanji (Parson) on Nov 06, 2001 at 02:30 UTC

    Speaking of perlfaq4 and stripping whitespace, check out trim() by japhy; a really neat sub that wraps and builds upon the FAQ-recommended solution.

        --k.