View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Eric Waters > Compress-LZW-Progressive-0.102 > Compress::LZW::Progressive



Annotate this POD


New  1
Open  0
View/Report Bugs
Module Version: 0.102   Source  


Compress::LZW::Progressive - Progressive LZW-like compression


  use Compress::LZW::Progressive;

  my $codec = Compress::LZW::Progressive->new();

  my $compressed = $codec->compress($data);


This module implements a progressive LZW-like compression technique. The progressive nature means that, in general, the more times you call $codec->compress(), the more efficient the codec will get (more highly compressed the data will be).


The codec is LZW-like because it has the following differences with Compress::LZW:

- Compressor can request the decompressor to delete a certain number of least frequently used codes - Stream will have a end_segment codeword at the end of a segment - Number of bits used is predefined, and cannot change.


new (...)

Creates a new codec for compressing and/or decompressing

reset ($which)

Reset the state of the compressor/decompressor. If $which is either 'compress' or 'decompress', it'll only reset that part. Otherwise, it'll reset both.

compress ($str)

decompress ($str)

Compress or decompress the string given and return the (de)compressed data.

stats ($show_phrases)

Prints efficiency statistics: how compressed the data is, how many code words used, how many Kb the dictionary is occupying in memory. If $show_phrases is true, it'll also spit out phrase length statistics in the dictionary.


For more efficiency, the codec should support outputting codes over less than two bytes. For example, a 12 bit compressed segment would be better expressed using 1.5 bytes per code, since you're not going to be using 4 bits of each output code using "pack 'S*'".


The LZW algorithim implemented here is not compatible with any other LZW implementation. It is a slight varient from that implemented in Compress::LZW, but don't expect it to work with any other LZW compressed data.


Copyright (c) 2006 Eric Waters and XMission LLC ( All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.


Eric Waters <>

syntax highlighting: