Hello monks
I use the following to discard stopwords, which are saved in an array, from my process
my $word="of"; my @stopwords= ("a","the","of"); if (grep /$word/i, @stopwords) { print "Stopword $word discarded\n"; } else{ print "$word is not a stop word\n"; }
This works fine if my $word has only one word, it just matches everywhere. It becomes complicated if $word is made out of more words, as I don't want to consider $word a stopword according to the position of the match. What I need to do is to exactily control the grep match, which means:
the position of the match, where the stopword is found in $word, for example at the beginning or at the end of $word. With $word="of the blue" match is true, $word="the blue of" match is true, $word="out of blue" match is no true
No idea where to start. I ould be glad if someone could give me some hint to work on.
In reply to grep match variable position by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |