in reply to Escaping quote marks

The answer if sort of in the question. But if you meant you want something more genereal:
s/(["'`])/'%'.unpack 'H*',$1/eg;
Or for every not alphanum char (and not quotes only):
s/(\W)/'%'.unpack 'H*',$1/eg;
Or perhaps you only want it for chars that can't be in a URI:
s/([^\w;\/?:\@&=\+\$,\[\]\-\.!~\*'\(\)])/'%'.unpack 'H*',$1/eg;