Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: can you please fix the error

by dbwiz (Curate)
on Jun 01, 2005 at 16:44 UTC ( #462548=note: print w/replies, xml ) Need Help??


in reply to can you please fix the error

Not the most efficient method, but anyway, assuming that both your files contain one word per line, the mistake is here:

WORD: foreach $word (@data) { STOP: foreach $stop (@stopwords) { next WORD if $word eq $stop; # <--- } push(@lessWords, $word); }

Whenever a stopword matches, you should exite the outer loop.

Consider using a hash instead.

my %stops = map {$_,undef} @stopwords; for my $word (@data) { next if exists $stops{$word}; push(@lessWords, $word); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://462548]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2023-06-02 18:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?