in reply to Re: regex verses join/split
in thread regex verses join/split

Interesting, but the OP wanted to remove leading/trailing spaces, and collapse any sequence of whitespaces into one single space. You propose to remove any whitespace anywhere, which is not what was asked for.

Still, it's true that tr/\n\r\f\t / /s would be more efficient than s/\s+/ /g. So, taking your remarks into account, I would say:

s/^\s+//; 1 while s/\s$//; tr/\n\r\f\t / /s;

--bwana147