in reply to can you please fix the error

You're directly comparing the stopwords against a paragraph of text. Split the paragraph into words before comparing. You might want to lowercase the words too, so case doesn't matter.

Replies are listed 'Best First'.
Re^2: can you please fix the error
by zulqernain (Novice) on Jun 01, 2005 at 17:49 UTC
    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
      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 :(