Hi,
 I wanted to recursively copy the contents of a directory(both directory and 
files) from one folder to the other.
   The below code does only copy of directories but leaves behind files.
   Can anybody help me how to do that ?
  Regards,
Alok
  
#!/usr/bin/perl
  $startDir = q{c:\test};
$newDir = q{c:\new};
  &myReadDir($startDir);
  exit 0; 
   
  sub myReadDir
{
        my ($dir) = @_;
        my (@dirs,$list);
        opendir(DIR,$dir) || warn "can't open the directory $dir: $!\n";
        @dirs=grep {!(/^\./) && -d "$dir\\$_"} readdir(DIR);        
        closedir (DIR);
        for $list(0..$#dirs)
        {
                mkdir ($newDir) unless -d $newDir;
                $ndir = $dir;
                $ndir =~ s/c:\\test/c:\\new/;
                print $ndir."\\".$dirs[$list],"\n";
                mkdir ($ndir."\\".$dirs[$list]);
                &myReadDir($dir."\\".$dirs[$list]);
        }
        return 1;
}
   

       
---------------------------------
No Cost - Get a month of Blockbuster Total Access now. Sweet deal for Yahoo! 
users and friends.

Reply via email to