John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:
OK, what did I do wrong? I thought I knew this stuff already...
Rather than replace every verboten character with the escape sequence, $linkref winds up being a string that contains only one escape sequence, even if the original string shouldn't have needed anything escaped at all.my $re= qr/[^-_.~A-Za-z0-9!*'();:@&=+\$,\/?#\[\]]/; use bytes; $linkref =~ s/($linkref)/sprintf("%%%02X",ord($1))/ge;
I know I'm making one or more basic errors here, but I'm just not seeing it. I need a break, and maybe another pair of eyes.
Thanks,
—John
P.S. writing \$1 instead of $1 doesn't fix it, though I do seem to be getting different single codes. It's stuck on %53 now, rather than being different each time.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex replacement goof
by wind (Priest) on May 07, 2011 at 01:08 UTC | |
by John M. Dlugosz (Monsignor) on May 07, 2011 at 01:14 UTC |