很多项目用VSS、SVN管理代码,这些软件往往会在代码目录里留下印迹,VSS会留下*.scc,SVN则在每个目录下放一个.svn。每次发布和拷贝时都得清理这些文件。为了偷懒,写了这个清理脚本,一劳永逸!
#!/usr/bin/perl
use File::Path;
use strict;
use warnings;
my @tree=<*>;
foreach (@tree){
&if_a_tree($_);
}
sub if_a_tree{
if(-d
&& $_ ne "."
&& $_ ne ".."){
print "$_ is a directory/n";
if ($_ eq ".svn")
{
rmtree $_;
return;
}
chdir $_;
my @tree=<* .*>;
foreach(@tree){
&if_a_tree($_);
}
chdir "..";
}
if(-f){
print "$_ just a file/n";
}
}