in reply to advice on improving performance of this code
Yes, but then you have to replace the '\s' with the equivalent escapes something like tr/\t\r\f\n //d to match all of what \s means. (assuming no locales or unicode)
Fun Fun Fun in the Fluffy Chair