title: What is an efficient way to search a huge file for many strings of characters?
body: <p>I'm trying to get back into Perl and having a bugger of time with my code.  I have a large source .DAT file (2GB).  I have another .TXT file that contains the strings (almost 2000 of them) I am wanting to search for in that .DAT file.  I throw the values from that .TXT file into an array.</p>
  
  <p>I want to efficiently do a search for each of those strings in the array, and output the matches.  Can anyone help straighten me out?  Thanks in advance!</p>
  
  <pre><code>my $source = "/KEYS.txt";
  my $data= "/claims.dat";
  my @array;
  my $arraySize = scalar (@DESYarray);
  
  open (DAT, $data) or die "Cannot open file!";
  open (LOG, "&gt;&gt;/output.log");
  
  open (TXT,$source);
  while (my $searchValues = &lt;TXT&gt;) {
      push (@array, $searchValues);
  }
  close (TXT);
  
  
  while (my $line = &lt;DAT&gt;) {      
  for (my $x = 0; $x &lt;= $arraySize; $x++) {
      if (my $line =~ /$array[$x]/) {
          print LOG $line;
      }
  }
  }
  
  close (DAT);
  close (LOG);
  </code></pre>