2014-03-25 35 views
0

我在內存中解壓縮.bz包時出現問題。我的腳本用於下載gzip包並將其解壓縮到內存中,並將其輸出發送到content()。在內存中解壓縮bzip2包

這是用gzip前工作但遺憾的是它不理解的bzip2包:

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

我試圖尋找相當於compresspackage沒有成功。我如何用bzip2包實現這個簡單的腳本?

回答

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

bunzip2(\$mech->content() => \my $packages) 
    or die("bunzip2 failed: $Bunzip2Error\n");