This all boils down to an interpolation problem. In your second run, your '\?' substrings are interpolated into mere '?'.
Try perl -e print "WTF\?\?\n". You should wind up with a return of WTF??.
So WTF?? does this have to do with the problem above? Well, $matchtext = "http://www.new.site/somenewpage.pl\?\?" interpolates to http://www.new.site/somenewpage.pl??. So you are running this regex: s#http://www.new.site/somenewpage.pl??#http://www.new.site/somenewpage.pl?:. Which isn't intended at all.
Use a non-interpolating quoting mechanism like q// or '' when you specify your $matchstring and your $replacestring. Also note that things like ?.* are safe in the second half of a substitution, of course you'll still need to escape \ and whatever character you are using as a delimiter (typically /)
TGI says moo
In reply to Re: Regular Expressions and Question Marks
by TGI
in thread Regular Expressions and Question Marks
by mr_dont
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |