perl 打开文件句柄

open (FILE,"<","cpbs.txt") || die "cannot open the file:$!
";
my @temp=<FILE>;
foreach (@temp) {
print "Found $_
";
}
close FILE;

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

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

原文地址:https://www.cnblogs.com/hzcya1995/p/13352067.html