title: Perl going through a list of folders
body: <p>I have a folder named Logs, which contains several folders Run 1, Run 1 (1), Run 2 (2), etc. Each of these folder contains a plist file which I need to parse through. But I am not able to open the file. I am running the code below:</p>
  
  <pre><code>my $count = 0;
  my $path  = "Logs/";
  
  for my $file (glob("${path}*/*Results.plist")) {
  
      # initialize parser object and find insances of Fail
      my $xp      = XML::XPath-&gt;new(filename=&gt;$file);
      my @nodeset = $xp-&gt;find('/dict/array/dict/string[1]');
  
      foreach my $element (@nodeset){
  
          if ($element-&gt;string_value == "Fail") {
  
              $count++;
          }
      }
  }
  
  print $count;
  </code></pre>
  
  <p>Edit: Now I need to look for "Fail" in the "string" child node. The plist file has 4 fails but my current code is returning only 2. Any ideas why?</p>
  
  <p>The plist file has a structure smilar to this:</p>
  
  <pre><code>&lt;plist version="1.0"&gt;
  &lt;dict&gt;
  &lt;key&gt;All Samples&lt;/key&gt;
  &lt;array&gt;
  &lt;dict&gt;
      &lt;key&gt;LogType&lt;/key&gt;
      &lt;string&gt;Fail&lt;/string&gt;
      &lt;key&gt;Message&lt;/key&gt;
      &lt;string&gt;Text&lt;/string&gt;
      &lt;key&gt;Timestamp&lt;/key&gt;
      &lt;date&gt;2012-10-17T08:01:51Z&lt;/date&gt;
      &lt;key&gt;Type&lt;/key&gt;
      &lt;integer&gt;4&lt;/integer&gt;
  &lt;/dict&gt;
  &lt;dict&gt;
      &lt;key&gt;LogType&lt;/key&gt;
      &lt;string&gt;Fail&lt;/string&gt;
      &lt;key&gt;Message&lt;/key&gt;
      &lt;string&gt;An error occurred while trying to run the script.&lt;/string&gt;
      &lt;key&gt;Timestamp&lt;/key&gt;
      &lt;date&gt;2012-10-17T08:20:46Z&lt;/date&gt;
      &lt;key&gt;Type&lt;/key&gt;
      &lt;integer&gt;7&lt;/integer&gt;
  &lt;/dict&gt;
  &lt;dict&gt;
      &lt;key&gt;LogType&lt;/key&gt;
      &lt;string&gt;Pass&lt;/string&gt;
      &lt;key&gt;Message&lt;/key&gt;
      &lt;string&gt;&lt;/string&gt;
      &lt;key&gt;Timestamp&lt;/key&gt;
      &lt;date&gt;2012-10-17T08:01:51Z&lt;/date&gt;
      &lt;key&gt;Type&lt;/key&gt;
      &lt;integer&gt;5&lt;/integer&gt;
  &lt;/dict&gt;
  &lt;/array&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>