http://qs321.pair.com?node_id=867109


in reply to Re: trimming space from both sides of a string
in thread trimming space from both sides of a string

What's wrong with:
$string =~ s/^\s*(.*?)\s*$/$1/;
I can't vouch for best speed in benchmarks, but works in any case I've needed such a construct for.