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 打开文件句柄
最新推荐文章于 2022-07-27 17:10:59 发布