in reply to untainting and locales and internationalisation

You must define your re to contain the characters you want EXPLICITLY. Which is better from a security point of view anyway. If you are not sure if a char is in a character class or not (which means it changes according to locale) then do something like
$re=join("",grep(/^\w$/,split(/(\w)/,"All chars you are prepared to de +al with")));