in reply to error:Global symbol "$stopwords" requires explicit package
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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: error:Global symbol "$stopwords" requires explicit package
by zulqernain (Novice) on Jun 01, 2005 at 14:48 UTC | |
by ikegami (Patriarch) on Jun 01, 2005 at 14:51 UTC | |
by zulqernain (Novice) on Jun 01, 2005 at 14:58 UTC | |
by Joost (Canon) on Jun 01, 2005 at 15:04 UTC |