title: How to ignore the single and double dot entries in Perl's readdir?
body: <p>Following up from here: <a href="https://stackoverflow.com/questions/21202690/perl-imgsize-not-working-in-loop/21202755?noredirect=1#21202755l">Perl Imgsize not working in loop?</a>
  I have another question - how do I not let perl list the single and double dot entries when it reads the files in a directory?</p>
  
  <p>As in the linked question above, my output to the while loop (<code>while ($file = readdir($dh))</code>) is something like this:</p>
  
  <pre><code>.
  ..
  file1.jpg
  file2.jpg 
  file3.jpg 
  file4.jpg 
  file5.jpg 
  </code></pre>
  
  <p>And this creates problems because I've also got a counter somewhere, which is counting my files. And <code>.</code> and <code>..</code> don't count as files, so my counter is giving a greater number of files in my directories than there really are.</p>
  
  <p>I added <code>if($file == "." || $file == ".."){ continue;}</code> and <code>if ($file ~ /^\./ or $file ~ /^\.\./) {continue;}</code> and different variations of that to the beginning of the while loop... but I keep getting an abort "due to compilation errors".</p>
  
  <p>How can we get a hold of the single and double dot entries?</p>