in reply to Re: error:Global symbol "$stopwords" requires explicit package
in thread error:Global symbol "$stopwords" requires explicit package

i am puting the stoplist sperated by \n from the file to the array of stopwords
open( LIST, "stopwords.txt" ) or die "$!"; my @stopwords = <LIST>;
as you suggested to use hash instead can you please tell me how i can put the stopwords read from file to the hash thanks

Replies are listed 'Best First'.
Re^3: error:Global symbol "$stopwords" requires explicit package
by ikegami (Patriarch) on Jun 01, 2005 at 14:51 UTC

    I already did:

    open( LIST, "stopwords.txt" ) or die "$!"; my @stopwords = <LIST>; chomp(@stopwords); # <- was missing my %stopwords; # Create an element in the hash for each stop word. undef @stopwords{@stopwords};

    or using less memory:

    # Create an element in the hash for each stop word. my %stopwords; open( LIST, "stopwords.txt" ) or die "$!"; while (<LIST>) { chomp; undef $stopwords{$_}; }

    Update: Added chomp.

      now it sgiving me same error for
      my %stopwords;