Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks
I'm matching strings (single words) contained in the array called @tokens against other strings (single words->stopwords) contained in the array called @stopords with the purpose of finding out if my strings (words) are present in the array, thus they are stopwords and I can discard them from the process. It is simple like that:
foreach my $token (@tokens) { if (grep /$token/i, @stopwords) { print "Stopword $token discarded\n"; } else { print "$token is okay\n"; } }
For some items in @tokens I get the following error message: An error occurred (Unmatched ) in regex; marked by <-- HERE in m/b) <-- HERE / at script.pm line 22
I guess it has to do with having meta characters in $token. But I don't know how to solve it in my example. Any suggestion will be appreciated
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: grep unmatch error
by Corion (Patriarch) on Mar 05, 2016 at 11:44 UTC | |
|
Re: grep unmatch error
by NetWallah (Canon) on Mar 05, 2016 at 23:29 UTC |