what's the fastest way to read a file line by line?
What is the fastest way to read a file line by line in 开发者_C百科perl?
open(my $fh, '<', 'fit.log') or die;
1. while(<$fh>){
blah, blah, blah
}
2. while(defined(my $line = <$filehandle>)){
blah, blah, blah
}
is #2 the same as #1?????
3. Tie::File
4. Any others?
As far as speed, the actual file i/o will almost certainly swamp any differences in how you write the surrounding loop. But benchmarking or profiling will give you the real answers.
精彩评论