title: script in perl to copy directory structure from the source to the destination
body: <pre><code>#!/usr/bin/perl -w
  use    File::Copy;
  use    strict;
  
  my   $i=  "0";
  my   $j=  "1";
  my   $source_directory = $ARGV[$i]; 
  my    $target_directory = $ARGV[$j];
  #print $source_directory,"\n";
  #print $target_directory,"\n";
  
  my@list=process_files ($source_directory);
  print "remaninign files\n";
  print @list;
  # Accepts one argument: the full path to a directory.
  # Returns: A list of files that reside in that path.
  sub process_files {
      my $path = shift;
  
      opendir (DIR, $path)
       or die "Unable to open $path: $!";
  
      # We are just chaining the grep and map from
      # the previous example.
      # You'll see this often, so pay attention ;)
      # This is the same as:
      # LIST = map(EXP, grep(EXP, readdir()))
      my @files = 
          # Third: Prepend the full path
          map { $path . '/' . $_}
          # Second: take out '.' and '..'
          grep { !/^\.{1,2}$/ }
          # First: get all files
          readdir (DIR);
  
      closedir (DIR);
  
      for (@files) {
          if (-d $_) {
              # Add all of the new files from this directory
              # (and its subdirectories, and so on... if any)
              push @files, process_files ($_);
  
          } else { #print @files,"\n";
            # for(@files)
          while(@files) 
          {  
          my $input= pop @files;
          print $input,"\n";
          copy($input,$target_directory);
  
               }
    }
        # NOTE: we're returning the list of files
     return @files;
    }
  }
  </code></pre>
  
  <p>This basically copies files from source to destination but I need some guidance on how to 
  copy the directory as well. The main thing to note here is no CPAN modules are allowed except copy, move, and path</p>