in reply to Regular Expressions and Question Marks

Like artist says, to handle wierdies like ?, you should use the \Q and \E features of the regular expression system.

Also, keep in mind that with double quotes, you are not really escaping your question marks at all. To see this, try printing your $matchtext. It's not what you intended! Compare the differences between the following two things:
$matchtext1 = "http://www.new.site/somenewpage.pl\?"; print "$matchtext1\n"; $matchtext2 = 'http://www.new.site/somenewpage.pl\?'; print "$matchtext2\n";
Single quotes preserve your backslash, double quotes use it, putting, as you asked, a literal quotation mark in your string. This is different from single quotes which put in a backslash then a question mark when presented with the same string.

Maybe that explains some of the mystery. For the rest, rememmber what ? does within a regex. You are in effect saying that the 'l' in "somepage.pl" is optional. Then you replace this text with something with an additional question mark. So, you get this:
s/somenewpage.pl??/somenewpage.pl?/
So, "somenewpage.p" turns into "somenewpage.pl?" and you still have the "l?" leftover. Hence, "somenewpage.pl?l?". Why does it do this? With a single question mark, it would be greedy and grab the 'l', since there is one there. The second question mark tells it to be conservative and use the shortest possible match, which in this case is the "0" part of "0 or 1 instances of" meaning of "?".

End result? Try this:
$matchtext = "http://www.foo.bar/somepage.pl?"; $substitutetext = "http://www.new.site/somenewpage?"; s/\Q$matchtext\E/$substitutetext/;