Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have some data that's serialized using Freeze::Thaw. It's a lot of data, though, so I'd like to be able to compress it after freezing it and decompress it before thawing it. What's the best way to compress/decompress scalar data?
  • Comment on What's the best way to compress a scalar?

Replies are listed 'Best First'.
Re: What's the best way to compress a scalar?
by johngg (Canon) on Feb 16, 2007 at 23:51 UTC
      Zlib will be in perl' s CORE with the next stable release:
      C:\>corelist -a Compress::Zlib Compress::Zlib was first released with perl 5.009003 5.009003 2.000_07 5.009004 2.000_13
      Also ActiveState is bundling it with ActivePerl for years and I think that it is and will be better supported than any other Compres::* module :)
Re: What's the best way to compress a scalar?
by friedo (Prior) on Feb 16, 2007 at 22:34 UTC
    I'm a fan of Compress::LZF which is pretty fast and very easy to use.
Re: What's the best way to compress a scalar?
by zentara (Cardinal) on Feb 17, 2007 at 13:12 UTC
    Another possibilty is to run some compression on it before freezing it.
    #!/usr/bin/perl use warnings; use strict; use Math::BaseCnv; #fast my $time = time; print "time -> $time\n"; my $time_128 = cnv( $time, 10, 128 ); print "time_128 -> $time_128\n"; #this will sometimes print hidden newlines exit;
    OUTPUT:
    time -> 1171717768 time_128 -> 4k#8

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: What's the best way to compress a scalar?
by andye (Curate) on Feb 20, 2007 at 12:22 UTC
    I'm using Compress::LZF on PDLs which I've frozen with Storable, and it's working well.