title: How to change an array into a hashtable?
body: <p>I'm trying to make a program where I read in a file with a bunch of text in it.  I then take punctuation out and then I read in a file that has stop words in it.  Both get read in and put into arrays.  I'm trying to put the array of the general text file and put it in a hash.  I'm not really sure what I'm doing wrong, but I'm trying.  I want to do this so I can generate stats on how many words are repeated and what not, but I have to take out stop words and such.  </p>
  
  <p>Anyway here is what I have so far I put a comment #WORKING ON MERGING ARRAY INTO HASH that is where I'm working at.  I don't think the way I'm trying to put the array into the hash is right, but I looked online and the %hash{array} = "value"; doesn't compile.  so not sure how else to do it.  </p>
  
  <p>Thanks, if you have any questions for me I will respond back quickly. </p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  
  #Reading in the text file
  my $file0="data.txt";
  open(my $filehandle0,'&lt;', $file0) || die "Could not open $file0\n";
  my@words;
  while (my $line = &lt;$filehandle0&gt;){
      chomp $line;
      my @word = split(/\s+/, $line); 
      push(@words, @word);
  }
  for (@words) {
      s/[\,|\.|\!|\?|\:|\;]//g;
  }
  my %words_count;  #The code I was told to add in this post. 
      $words_count{$_}++ for @words;
  </code></pre>
  
  <p>Next I read in the stop words I have in another array.  </p>
  
  <pre><code>#Reading in the stopwords file
  my $file1 = "stoplist.txt"; 
  open(my $filehandle1, '&lt;',$file1) or die "Could not open $file1\n";
  my @stopwords;
  while(my $line = &lt;$filehandle1&gt;){
      chomp $line;
      my @linearray = split(" ", $line);
      push(@stopwords, @linearray);
  }
  for my $w (my @stopwords) {
      s/\b\Q$w\E\B//ig; 
  }
  </code></pre>