精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>● CGI>>编程技巧>>Re: PERL有什么语句可以删除有文件的文件夹?

主题:Re: PERL有什么语句可以删除有文件的文件夹?
发信人: brucech@GZ()
整理人: workingnow(2002-09-30 12:01:53), 站内信件

标  题: Re: PERL有什么语句可以删除有文件的文件夹?
发信站: 网易虚拟社区 (Wed Jun 14 16:42:30 2000), 站内信件

【 在 jary2000 (jary2000) 的大作中提到: 】

好象没有现成的,需要自己编写,可以自己编写一个简单的!
我这儿有一段,你直接拿去可以用的!采用的是递归调用方式!
##########

sub deldir {

my($del_dir)=$_[0];
my(@direct);
my(@files);
opendir (DIR2,"$del_dir");
my(@allfile)=readdir(DIR2);
close (DIR2);
foreach (@allfile){
if (-d "$del_dir/$_"){
push(@direct,"$_");
}
else {
push(@files,"$_");
}
}

$files=@files;
$direct=@direct;
if ($files ne "0"){
foreach (@files){
unlink("$del_dir/$_");
}
}
if ($direct ne "0"){
foreach (@direct){
&deldir("$del_dir/$_") if($_ ne "." && $_ ne "..");
}
}

rmdir ("$del_dir");
}


--
秋风扫落页的清凉世界
   |
   |---> CGI、PHP程序的交流、汉化、演示、下载
                |
                |--->  http://brucech.yeah.net

※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.109.0.85]

[关闭][返回]