stopwords contain a list of stopwords,
That error means $stopwords is not declared (my or our). If you have a list of stop words, I presume it's in @stopwords rather than $stopwords? If so, you need a second loop to scan over your list of stop words.
WORD: foreach $word (@data) { foreach my $stopword (@stopwords) { next WORD if $word eq $stopword; } push(@lessWords, $word); } print "@lessWords\n";
Instead of using a second loop, you could speed up things greatly (if you have more than a couple of @words) by using a hash.
my %stopwords; # Create an element in the hash for each stop word. undef @stopwords{@stopwords}; foreach $word (@data) { next if exists $stopword{$word}; push(@lessWords, $word); } print "@lessWords\n";
In reply to Re: error:Global symbol "$stopwords" requires explicit package
by ikegami
in thread error:Global symbol "$stopwords" requires explicit package
by zulqernain
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |