in reply to RE: pattern matching: why does the following code evaluate true? (and how do i fix it?)
in thread pattern matching: why does the following code evaluate true? (and how do i fix it?)

Well, /^$key2$/, wouldn't match--there's nothing greedy in that regex. But since the pattern isn't anchored it looks for the $key2 pattern anywhere in $key.

If you're looking for literal periods, do one of the following:

$key2 = "INITIAL\.LASTNAME,INITIAL2\.LASTNAME2,\."; $key2 = quotemeta "INITIAL.LASTNAME,INITIAL2.LASTNAME2,."; $key =~ /\Q$key2/
  • Comment on RE: RE: pattern matching: why does the following code evaluate true? (and how do i fix it?)
  • Download Code