Frage

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?

War es hilfreich?

Lösung

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

bunzip2(\$mech->content() => \my $packages)
   or die("bunzip2 failed: $Bunzip2Error\n");
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top