in reply to Re: Untainting cookies
in thread Untainting cookies

How about just tr'ing the initial Base64 ID like so:
$id =~ tr|+/=|___|; # or $id =~ tr|+/=|000|;
You would lose just a few bits of randomness (acceptable in this application), but would be left with a shorter ID that's an easy match with a /\w/.
   MeowChow                                   
               s aamecha.s a..a\u$&owag.print