Strangely enough, you've hit a regular expression gotcha.
The empty regular expression has a special meaning: try again the last regular expression that successfully matched. What is perhaps less obvious is that perl checks for an empty expression after interpolating variables, such as the \Q$exp_sender\E in your example.
Here's a snippet to illustrate:
"test" =~ /t/; # successful match my $var = ""; print "matched 't'\n" if "t" =~ /\Q$var\E/; print "matched 'u'\n" if "u" =~ /\Q$var\E/;
A couple of alternative approaches, depending on what you're trying to achieve:
Hugoprint "'$signer' is not '$exp_sender'\n" unless $signer eq $exp_sender; print "'$signer' is not '$exp_sender'\n" unless index($signer, $exp_sender) >= 0; print "'$signer' is not '$exp_sender'\n" unless $exp_sender eq '' || $signer eq $exp_sender;
In reply to Re: Regular Expression gotchas ?
by hv
in thread Regular Expression gotchas ?
by the_Don
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |