KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Suppose I have a file containing lines I'm trying to match against: foo quux bar In my code, I have another array: foo baz quux Let's say we iterate through the file, calling each element $word , and the internal list we are checking against, @arr . if( grep {$_ =~ m/^$word$/i} @arr) This works correctly, but in the somewhat possible case where we have an test case of fo. in the file, the . operates as a wildcard operator in the regex, and fo. then matches foo , which is not acceptable. This is of course because Perl is interpolating the variable into a regex. The question: How do I force Perl to use the variable literally?
Tags (comma-separated)
Save Edits
Cancel