prescott2006 has asked for the wisdom of the Perl Monks concerning the following question:

Is there any method to read .bz2 directly without using module IO::Uncompress::Bunzip2?

Replies are listed 'Best First'.
Re: Alternative to IO::Uncompress::Bunzip2
by Corion (Patriarch) on Apr 09, 2012 at 07:40 UTC

    Yes - see the pipe form of open. You need the bunzip2 executable installed for that:

    my $cmd = sprintf 'bunzip2 -cd "%s"', $filename; open my $fh, "$cmd |" or die "Couldn't launch [$cmd]: $!"; binmode $fh; print while <$fh>;

    Update: Fixed missing filename argument, spotted by AnomalousMonk

    A reply falls below the community's threshold of quality. You may see it by logging in.