I am trying to write a Perl script, a part of which is to match strings from one file with another file, and print out further information from the appropriate line of the file if there is a match. Mostly this is working fine, other than in cases where the text that needs to be matched contains parentheses or brackets.
In these cases, the a match does not occur even if the strings are exactly the same. I have confirmed that this is the case for the troublesome examples. I have a good idea that it is something to do with parentheses being ‘metacharacters’, but attempting to escape the brackets by putting backslashes before them in both files (at an earlier stage in the script) produced the following error in the matching routine:
Unmatched ) in regex; marked by <-- HERE in m/^) <-- HERE / at datafile_parser.pl line 139, <DATA_TOMATCH_IN> line 219
What am I doing wrong?