title: Read file content and use Regular Expression to locate a pattern in each File in Perl
body: <p>I have about 200 files located in the same directory, all of which contain a specific piece of content that I need to match using RegExp and either save all of the matched contents into a single array or store them in a new file. </p>
  
  <p>When working with notepad++ regexp engine I do the following to locate the pattern:</p>
  
  <pre><code>&lt;div class="opacity description"&gt;(.*)&lt;/div&gt;
  </code></pre>
  
  <p>so that is the pattern I am looking for. </p>
  
  <p>And this is how i Open and List all the files in the directory.</p>
  
  <pre><code>my $d = shift;
  
  opendir(D, "details/") || die "Can't opedir $d: $!\n";
  my @list = readdir(D);
  closedir(D);
  
  foreach my $f (@list) {
    print "\$f = $f\n";
  }
  </code></pre>