Question

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?

Was it helpful?

Solution

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

bunzip2(\$mech->content() => \my $packages)
   or die("bunzip2 failed: $Bunzip2Error\n");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top