title: Why is running opendir, readdir, stat so slow compared to the Windows dir command?
body: <p>I have a Perl script that is using <code>opendir</code> to read the contents of a directory:</p>
  
  <pre><code>opendir ( DIR, $path ) or next;
      while (my $file = readdir DIR) {
  </code></pre>
  
  <p>Then I'm doing:</p>
  
  <ul>
  <li><code>-s $file</code> to get the size of each file</li>
  <li><code>(stat($file))[9]</code> to get the modified time of each file</li>
  </ul>
  
  <p>I'm running this from a Windows machine and accessing a Samba share on Ubuntu 14.04.</p>
  
  <p>This is all working fine but the process seems to run very slow compared to when I run a <code>dir</code> listing on the same folder.</p>
  
  <p>Does anyone know why using <code>opendir</code> takes so much longer than a <code>dir</code> listing and if there's any way I can change my script to speed it up?</p>