in reply to Re: can you please fix the error
in thread can you please fix the error

you were right i was comparing the whole paragrapgh with a word and that why $word and $stopword were never equal.$word has a full paragraph. now i have fixed that (i hope). but its still not working :(
foreach $word (@data) { my @arr=split(/ /,$word); WORD: foreach $a (@arr) { STOP: foreach $stop (@stopwords) { next WORD if $a eq $stop; } } push(@lessWords, $word); } print "@lessWords\n";
plz help

Replies are listed 'Best First'.
Re^3: can you please fix the error
by Joost (Canon) on Jun 01, 2005 at 17:53 UTC
    You're still pushing $word onto @lessWords regardless of the match. Simple fix:
    foreach $word (@data) { my @arr=split(/ /,$word); WORD: foreach $a (@arr) { foreach $stop (@stopwords) { next WORD if $a eq $stop; } push(@lessWords, $word); } }
    using a hash for @stopwords would make this code simpler and faster, though. There are some examples in this thread somewhere.

    update: the above code is still buggy. See below for a much simpler version that should work.

      it did not work either ...it just put the same text many a times ...does not remove the stopwords :(