开发者

what's the fastest way to read a file line by line?

开发者 https://www.devze.com 2023-03-22 01:31 出处:网络
What is the fastest way to read a file line by line in 开发者_C百科perl? open(my $fh, \'<\', \'fit.log\') or die;

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

精彩评论

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