in reply to Re: Re: Regular Expression gotchas ?
in thread Regular Expression gotchas ?
It isn't $&, it is an invisible "what pattern did the last successful match use?" saved for just this purpose.
I think the easiest way to clear it out (if I guess correctly what you mean by that) is to find a pattern that acts like the empty pattern would were it not special-cased. The simplest one I know is the empty lookahead:
"" =~ /(?=)/;
That'll always match, and do so pretty quickly; once matched, it'll be remembered as the last successful match, so an empty pattern will use it and always match.
But be warned that this is an ugly workaround that'll make your code harder to write in the first place, and harder to maintain in the future. Better by far would be to avoid the problem in the first place.
Since the original check, $signer =~ m/\Q$exp_sender\E/, is identical to:
except for the special-case behaviour on the empty pattern, I suspect the latter is what you actually want. Hugoindex($signer, $exp_sender) > 0
|
|---|