I need to check whether a given phrase is present in a text string or not. I have to check this for a number of phrases (>100 thousand phrases). All the phrases are given in a text file. What I am doing is that reading all the phrases one by one, in a variable $testPhrase and then use a regular expression to check whether this phrase is present in the text string or not. The problem is that some of these test phrases might contain certain special characters like ?,+ etc. How to prevent perl from treating them as a special character? One way is to use a regular expression for the test phrase itself and escape all the special characters that are present in the test phrase. Is there an easier/simpler way to achieve this?
For example: suppose the test phrase is c++. It is stored in $testPhrase. I need to check whether $testPhrase is present in $string or not. How to prevent perl to treat + in c++ as special characters?