Thanks merlyn, that seems to work.
I am familiar with and agree with your position of not using home-grown code whose function is already performed by widely-used modules. I don't like, however, the way that URI::Escape evals whatever I pass it and I was thinking of using URI::Escape's internal regex myself directly on the values to give me more control, not to mention a modest perfomance benefit.
#build a char->hex map
for (0..255) {
$escapes{chr($_)} = sprintf("%%%02X", $_);
}
$text =~ s/([^A-Za-z0-9\-_.!~*'()])/$escapes{$1}/g;
Do you think this would be a mistake?