What is the best way to gunzip files with Perl?

后端 未结 4 617
面向向阳花
面向向阳花 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:55

    And I also don't understand why while (<$z>) is slower than while (my $line = $z->getline())...

    Because $z is a self tied object, tied objects are notoriously slow, and <$z> uses the tied object interface to call getline() rather than directly calling the method.

    Also you can try PerlIO-gzip but I suspect it won't be any/much faster than the other module.

提交回复
热议问题