Am currently writing a script in perl to parse the perl modules and fetch meaningful words from them. (other than perl keywords).
I have a rejection list array which contains the perl keywords. I use this to separate the meaningful words from the perl keywords.
my $pattern = join("|", @rejectionlist);
foreach my $word (@words) {
if (!($word =~ /^$pattern$/i)) {
push @meaningfulwords, $word;
}
}
Is it possible to dynamically generate the perl keywords (rejection list array - by using any routines) ?
If you really want to use regex for this kind of task, you should escape each keyword before you joint them into list. Insert
\Q
at the beginning of the keyword and\E
at the end of the keyword.