Вопрос

I have a problem with uncompressing .bz package in memory. My script used to download gzip package and it uncompressed in the memory and sent its output to content().

This was working before with gzip but unfortunately it does not understand bzip2 package:

$mech = WWW::Mechanize->new;
$mech->get("$url/pkg.gz");
$packages = Compress::Zlib::memGunzip($mech->content())

I tried to look for equivalent compresspackage without a success. How I can implement this simple script with bzip2 package?

Это было полезно?

Решение

use IO::Compress::Bunzip2 qw( bunzip2 $Bunzip2Error );

bunzip2(\$mech->content() => \my $packages)
   or die("bunzip2 failed: $Bunzip2Error\n");
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top