DishBreak
September 17th, 2009, 12:18 AM
Hi all,
I'm playing with a perl script that does a comparison of two files. Because the order can be jumbled between the files, a simple line-by-line diff won't work.
I've been using the grep() function in Perl as follows.
@matches = grep (/$searchTerm/, @fileLines);
This works well...except when the $searchTerm scalar contains special characters (i.e. $, +, etc.) Instead of taking these characters literally, they're taken to be significant to the the regex.
What can I do to make sure the string is taken literally? I'm almost at the end of my rope, so anything would help.
I'm playing with a perl script that does a comparison of two files. Because the order can be jumbled between the files, a simple line-by-line diff won't work.
I've been using the grep() function in Perl as follows.
@matches = grep (/$searchTerm/, @fileLines);
This works well...except when the $searchTerm scalar contains special characters (i.e. $, +, etc.) Instead of taking these characters literally, they're taken to be significant to the the regex.
What can I do to make sure the string is taken literally? I'm almost at the end of my rope, so anything would help.