title: Using Perl how can I clean up left over directories with no files?
body: <p>There is a specific directory which is used as a temp/scratch directory by some program.<br>
  E.g. <code>/a/b/c/work</code><br>
  Under work multiple hierarchical directories may exist e.g.  </p>
  
  <pre><code>/a/b/c/work/  
              \d1/   
                 \d1.1  
               \d2
                  \d2.2  
  </code></pre>
  
  <p>What I want is to clean up this work directory as there are left over files that take space.<br>
  Essentially I need to delete all subdirectories under work that the leaf directory is empty.<br>
  So if d1.1 is empty but d2.2 has files then delete everything under d1 (including d1) but not d2.<br>
  What is the cleanest/standard way to do this in perl?<br>
  I thought to use a solution with backticks e.g. rm -rf etc but I thought there could be some better way than coding sequences of ls folowed by rm  </p>
  
  <p><strong>Note:</strong> Just to be clear. I want a solution in Perl as this is not a one time thing and I dont want to do this manually each time</p>