title: Perl - enhance code to recursively count files
body: <p>I am new to Perl and am trying to learn the language but am having a difficult time doing something that I think is probably simple.</p>
  
  <p>I have been able to get a script working that will count the just the number of files in a directory.  I would like to enhance the script to recursively count all files in any sub directories also.  I have searched and found a few different options for GLOB and File::Find, but have not been able to get them to work.</p>
  
  <p>My current code:</p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  
  use Path::Class;
  
  # Set variables
  
  my $count = 0;  # Set count to start at 0
  my $dir = dir('p:'); # p/
  
  # Iterate over the content of p:pepid content db/pepid ed
  while (my $file = $dir-&gt;next) {   
  
  
      next if $file-&gt;is_dir();    # See if it is a directory and skip
  
  
      print $file-&gt;stringify . "\n";   # Print out the file name and path
      $count++   # increment count by 1 for every file counted
  
  }
  
  
  print "Number of files counted " . $count . "\n";
  </code></pre>
  
  <p>Can anyone help me enhance this code to recursively search any sub directories as well?</p>