print "Content-type: text/html\n\n"
open(destfile,"c:/menu.lst")
while(<destfile>)
{
$n=$n+1
}
$N=int(rand($n))
close(destfile)
print "<html><h1>总行数$n行 <br>随机取$N行</h1></html>\n"
#读取文件行数n,设定$N<$n,随机取小于n的整数N.
open(destfile,"c:/menu.lst")
while(<destfile>)
{
$c=$c+1
print $_ if ($c==$N)
}
close(destfile)
windows下随便写的,版本perl 5.10.1
1、获取目录下所有文件名my $dir = '你的目录'
opendir( DIRHANDLE, "$dir" ) or die "can not open dir"
my @allfile = readdir(DIRHANDLE)
closedir (DIRHANDLE)
2、改名字
foreach $old (@allfile){
rename("$dir/$old","$dir/$new")
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)