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;
一次读入一行,可以减少内存占用。