in reply to Regular Expression gotchas ?
Thus the following command is evaluated regardless of filename:yet sometimes an error is created, sometimes not.$error ||= "Unexpected signer 'GOODSIG 86125876138571635 ClientKey' is + not ''." unless ('GOODSIG 86125876138571635 ClientKey' =~ m/\Q\E/);
If the error is created, that's because it is set elsewhere. The code you gave will not change $error when $expected_signer is an empty string. That's because m/\Q$foo\E/ will match anything when $foo is empty. (Every string contains an empty string.) In this snippet, $error is only set unless the match is true. Since it is true, $error isn't set.
Update: Changed "Every string matches an empty string" to "Every string contains an emptry string." The latter is what I really meant (as the context implies.) My thanks go to Enlil for spotting it.
-sauoq "My two cents aren't worth a dime.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regular Expression gotchas ?
by the_Don (Scribe) on Feb 17, 2003 at 08:13 UTC | |
by hv (Prior) on Feb 17, 2003 at 13:43 UTC | |
by the_Don (Scribe) on Feb 18, 2003 at 22:18 UTC | |
by hv (Prior) on Feb 18, 2003 at 22:50 UTC |