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

Howdy I am trying to actually use Compress::LZF_PP. So I thought I would give it a test and I compressed a string using Compress::LZF and check if LZF_PP can decompress it.

Not sure what am I doing wrong...

use Compress::LZF; use Compress::LZF_PP; use strict; my $contents = q{ A123456789 123456789 123456789 123456789 123456789 123456789 B123456789 123456789 123456789 123456789 123456789 123456789 }; print STDERR $contents; my $compressed = Compress::LZF::compress($contents); my $uncompressed = Compress::LZF_PP::decompress($compressed); print STDERR "----------------------------------"; print STDERR $uncompressed;

Result is:

A123456789 123456789 123456789 123456789 123456789 123456789 B123456789 123456789 123456789 123456789 123456789 123456789 ---------------------------------- A123456789 123456789 123456789 123456789 123456789 123456789 B6789 123456789 123456789 123456789 123456789 1234A123456789

Replies are listed 'Best First'.
Re: Is Compress::LZF_PP compatible with Compress::LZF?
by RMGir (Prior) on Dec 12, 2011 at 12:44 UTC
    I'm not sure, since I've never used either module.

    But what happens if you do the decompress with LZF instead of LZF_PP? If that DOES get you the original string, then it does seem likely they're incompatible.

    Also, does the round-trip work if you compress/decompress with LZF_PP?


    Mike
      Yes - roundtrip with Compress::LZF works fine. But files that I dealing were compressed with some funky Java implementation of Ziv-Lempel - I tried decompressing them using LZF and it failed - so I thought I would try LZF_PP so I can at least debug what is going wrong. But as it seems LZF_PP has some issues...
Re: Is Compress::LZF_PP compatible with Compress::LZF?
by Khen1950fx (Canon) on Dec 13, 2011 at 09:02 UTC
    First, get rid of Compress::LZF_PP. Second, there's no need to print contents to STDERR. You won't need to. Here's what I used:
    #!/usr/bin/perl use strict; use warnings; use Compress::LZF qw(:compress); my $contents = q( A123456789 123456789 123456789 123456789 123456789 123456789 B123456789 123456789 123456789 123456789 123456789 123456789 ); print "-" x 60; my $compressed = compress($contents); my $decompressed = decompress($compressed); print $decompressed;
    Note that Compress::LZF only works with liblzf. In other words, the data must be compressed and decompressed with liblzf exclusively. It won't work with Java-based versions of the algorithm.
      Thanks - that is important fact. I think I will have to dig out source of Java program that does compression and work from there.