Well, this does seem curious:
$ perl -v
This is perl, v5.6.1 built for i586-linux
...
$ perl -e '$u="http://www.domain.com/hi.html?a=b&c=d";
print $u,$/;
$u=~s/(.*?)\?(.*?)/$1/gs;
print $u,$/;'
produces:
http://www.domain.com/hi.html?a=b&c=d
http://www.domain.com/hi.htmla=b&c=d
But you said that you only wanted the first part (before the
"?"), so why did you put parens around the second part? It
does work as desired this way:
$ perl -e '$u="http://www.domain.com/hi.html?a=b&c=d";
print $u,$/;
$u=~s/(.*?)\?.*/$1/;
print $u,$/;'
http://www.domain.com/hi.html?a=b&c=d
http://www.domain.com/hi.html
For that matter, whether or not you use the following
part as well, why not
split:
$ perl -e '$u="http://www.domain.com/hi.html?a=b&c=d";
print $u,$/;
($ub,$ue)=split(/\?/,$u,2);
print "$ub :: $ue",$/;'
http://www.domain.com/hi.html?a=b&c=d
http://www.domain.com/hi.html :: a=b&c=d
Still, the initial example is baffling, and I hope someone
can explain why it should behave the way it did, just for
our communal peace of mind. The final "gs" is of course
superfluous for this example -- the behavior is the same
with or without those qualifiers on the regex. (And "extra
strength" is not really an appropriate reason for using them,
anyway; check their descriptions in
perlre to see what their
proper, intended functions are.)