in reply to taint check that I thought worked

I'm pretty sure you just overlooked this...in the line
$tainted =~ /\A([a-zA-Z0-9]{1-16})\z/i

I think you wanted a comma in the {1,16}.

HTH,
Chris