What is the best way to gunzip files with Perl?

后端 未结 4 623
面向向阳花
面向向阳花 2021-01-16 07:12

Is there a faster solution than my actual \'zcat\' solution to gunzip files with Perl?

A little benchmark:

#!/usr/bin/perl

use strict;
use warnings;         


        
4条回答
  •  南笙
    南笙 (楼主)
    2021-01-16 07:54

    The last time I tried it, spawning an external gunzip was considerably faster than using a Perl module (just like your benchmarks show). I suspect it's all the method calls involved in tying a filehandle.

    I expect <$z> is slower than $z->getline for a similar reason. There's more magic involved in figuring out that the first needs to be translated into the second.

提交回复
热议问题