perl 打开文件句柄

前端之家收集整理的这篇文章主要介绍了perl 打开文件句柄前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
open (FILE,"<","cpbs.txt") || die "cannot open the file:$!\n";
my @temp=<FILE>;
foreach (@temp) {
print "Found $_\n";
}
close FILE;

读入大型文件:
open (FILE,"cpbs.txt") || die "cannot open the file:$!\n";
while (<FILE>){
print "Found $_\n";
}
close FILE;

一次读入一行,可以减少内存占用。

猜你在找的Perl相关文章