質問

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