Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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
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 browsing the Monastery: (6)
As of 2020-10-20 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (210 votes). Check out past polls.

    Notices?