in reply to Re^4: Stupid question about strings...
in thread Stupid question about strings...
So why did the code I showed return true (or "foo")?"
The first part of my previous message with its two examples was intended to show with a simpler example on which sides of the binding operator each string should be.
The second part of my message was intended to show with three additional examples where the error was in your example and how to correct it.
Basically, since you put $str1 on the right side of the operator and did not quotemeta it and also did not escape the pipe characters, $str1 is interpreted as a regex and the pipe considered as an alternation within this regex. The "|L|D|" regex matches either an L, or a D, or any other character, so that in the end it matches pretty much anything.
Escaping the pipe characters ("\|L\|D\|"), or using the quotemeta \Q operator, as I did in my examples corrects the issue.
|
|---|