perl学习笔记八——文件读写

前端之家收集整理的这篇文章主要介绍了perl学习笔记八——文件读写前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一,perl对文件读写的处理

点击打开链接

检查当前目录下是否有test.pl文件,如果有则提示

@test=`dir 2>&1`;
if (open(MYFILE,">>cycle5_log.txt")) {
print MYFILE (@test);     
    }
else{
               print "creat new file error!\n";
}
$testout = @test;
if($testout > 0)
{
                foreach $testr (@test)
                {
                                #print $testr;
                                if ($testr =~ m/test.pl/)
                                {
                                                print "test.pl is exist";
                                }
                }
}
close(MYFILE);

猜你在找的Perl相关文章