use Compress::Zlib ; use Storable ; my %hash = &some_data ; my $data = pack( "u*", Compress::Zlib::MemGzip( freeze \%hash) ) ; # now you can do as you please with $data # to unthaw: my $hashref = thaw( Compress::Zlib::MemGunzip( unpack( "u", $data ) ) ) ;