开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜