title: Error - For all subdirectories under a main dir - create a list of files within each subdirectory
body: <p>I am trying to generate individual list of files inside each subdirectory under one given directory. This may be an already addressed and resolved problem, but my specific issue is that my sub directories will always have a pattern in name and also have exact number files for eg - </p>
  
  <pre><code> &lt;**Main_Dir**&gt;
  
  &lt;sub-directory&gt;- sub1_dir with files 
      sub1.name.txt
      sub1.place.txt
      sub3.time.txt
      sub4.date.txt
  
  &lt;sub-directory&gt;- sub2_dir with files 
      sub2.name.txt
      sub2.place.txt
     ..............
  
  &lt;sub-directory&gt;- sub3_dir with files 
          sub3.name.txt
         ...............
         .......
  </code></pre>
  
  <p>Is there a way to make the code loop over each sub* subfolder, since I know the pattern/name for these main folders will remain like this? 
  In short the script should create a file under each subdirectory with list of files in it. </p>
  
  <p>Eg - </p>
  
  <pre><code>&lt;sub-directory&gt;- sub1_dir with files 
          List_sub1_dir.txt
          sub1.name.txt
         ..............
  &lt;sub-directory&gt;- sub2_dir with files 
          List_sub2_dir.txt
        ...............
  </code></pre>
  
  <p><strong>My edited code</strong> -  <strong>It does not create any list file in the subfolder</strong> Can someone please help me find the error? Thanks a lot!! </p>
  
  <pre><code>    use strict;
  use warnings;
  
  use File::Find::Rule;
  my $directory = './Maindir';
  
  my @subdirs = File::Find::Rule-&gt;directory-&gt;in( $directory );
  
  foreach my $dir (@subdirs) {
          #print "$dir\n";
          next if ($dir eq "..");
  
          if (-d $dir)
          {
          my @files = File::Find::Rule-&gt;file() -&gt;name( '*.*' ) -&gt;in( $di
  +r);
  
          foreach my $file (@files)
                  {
          open (FH,"$file");
  
  
          while (&lt;FH&gt;)
          {
          open FILE,"&gt;&gt;./$dir.txt" or die $!;
          print FILE "$_";
          }
          close(FH);
          close FILE;
  
          #print  "$file\n";
  
                  }
  
  
          }
  </code></pre>