in reply to Re: Re: Using a variable as pattern in substitution
in thread Using a variable as pattern in substitution
You can chomp every element in the array when you slurp the file: chomp(@stopwords = <FILE>);(As a side note, in general, chomp is preferable to chop.)
The \b says to look for a word boundary. In other words, if your target string is part of another word, the \b will keep it from matching.
You can read more about it in the perlre document.my $target = "another"; $target =~ /other/; # this matches $target =~ /\bother/; # this doesn't
|
|---|