title: Recursive Perl detail need help
body: <p>i think this is a simple problem, but i'm stuck with it for some time now! I need a fresh pair of eyes on this.</p>
  
  <p>The thing is i have this code in perl:</p>
  
  <pre><code>#!c:/Perl/bin/perl
  use CGI qw/param/;  
  use URI::Escape; 
  
  print "Content-type: text/html\n\n";
  
  my $directory = param ('directory'); 
  $directory = uri_unescape ($directory); 
  
  my @contents;
  readDir($directory);
  
  
  foreach (@contents) {
    print "$_\n";
  }
  
  #------------------------------------------------------------------------
  sub readDir(){
   my $dir = shift;
      opendir(DIR, $dir) or die $!;
      while (my $file = readdir(DIR)) {
    next if ($file =~ m/^\./);
    if(-d $dir.$file)
    {
     #print $dir.$file. " ----- DIR\n";
     readDir($dir.$file);
    }
    push @contents, ($dir . $file);
      }
      closedir(DIR);
  }
  </code></pre>
  
  <p>I've tried to make it recursive. I need to have all the files of all of the directories and subdirectories, with the full path, so that i can open the files in the future.</p>
  
  <p>But my output only returns the files in the current directory and the files in the first directory that it finds. If i have 3 folders inside the directory it only shows the first one.</p>
  
  <p>Ex. of cmd call: </p>
  
  <pre><code>"perl readDir.pl directory=C:/PerlTest/"
  </code></pre>
  
  <p>Thanks</p>