#!/usr/bin/perl

# recursively goes through directory tree and removes the .svn
# dir in each, which removes the code from SVN control

$dirToSearch = `pwd`;
@foo = split("\n", $dirToSearch);
$dirToSearch = $foo[0];
doDir();

# SUBROUTINEs
#============================================================

sub doDir
 { my @fileNames;
   my $dirSearching = $dirToSearch;
   print "doing dir: $dirSearching\n";
   
   $dired = `ls -a $dirSearching`;
   @fileNames = split("\n", $dired);
   #print "filenames: ";
   foreach $fileName (@fileNames)
    { #print " $fileName ";
      stat "$dirSearching/$fileName";
      if( -d "$dirSearching/$fileName" )
       { if( $fileName  =~ /\.svn/ ) 
          { print "found SVN: $fileName\n";
            `rm -Rf $dirSearching/$fileName`;
          }
         elsif( !( $fileName =~ /\.|\.\./ ) )
          { $dirToSearch = "$dirSearching/$fileName";
            doDir();
          }
       }
    }
 }
