1 |
root |
1.1 |
=head1 NAME |
2 |
|
|
|
3 |
|
|
Compress::LZF - extremely leight-weight Lev-Zimpel-Free compression |
4 |
|
|
|
5 |
|
|
=head1 SYNOPSIS |
6 |
|
|
|
7 |
|
|
# import compress/decompress functions |
8 |
|
|
use Compress::LZF; |
9 |
|
|
# the same as above |
10 |
|
|
use Compress::LZF ':compress'; |
11 |
|
|
|
12 |
|
|
$compressed = compress $uncompressed_data; |
13 |
|
|
$original_data = decompress $compressed; |
14 |
|
|
|
15 |
|
|
# import sfreeze, sfreeze_cref and sfreeze_c |
16 |
|
|
use Compress::LZF ':freeze'; |
17 |
|
|
|
18 |
|
|
$compressed = sfreeze_c [4,5,6]; |
19 |
|
|
$original_data = sthaw $compressed; |
20 |
|
|
|
21 |
|
|
=head1 DESCRIPTION |
22 |
|
|
|
23 |
|
|
LZF is an extremely fast (not that much slower than a pure memcpy) |
24 |
|
|
compression algorithm. It is ideal for applications where you want to save |
25 |
|
|
I<some> space but not at the cost of speed. It is ideal for repetitive |
26 |
|
|
data as well. The module is self-contained and very small (no large |
27 |
|
|
library to be pulled in). It is also free, so there should be no problems |
28 |
|
|
incoporating this module into commercial programs. |
29 |
|
|
|
30 |
|
|
I have no idea wether any patents in any countries apply to this |
31 |
|
|
algorithm, but at the moment it is believed that it is free from any |
32 |
|
|
patents. |
33 |
|
|
|
34 |
|
|
=head1 FUNCTIONS |
35 |
|
|
|
36 |
|
|
=head2 $compressed = compress $uncompressed |
37 |
|
|
|
38 |
|
|
Try to compress the given string as quickly and as much as possible. In |
39 |
|
|
the worst case, the string can enlarge by 1 byte, but that should be the |
40 |
|
|
absolute exception. You can expect a 45% compression ratio on large, |
41 |
|
|
binary strings. |
42 |
|
|
|
43 |
|
|
=head2 $decompressed = decompress $compressed |
44 |
|
|
|
45 |
|
|
Uncompress the string (compressed by C<compress>) and return the original |
46 |
|
|
data. Decompression errors can result in either broken data (there is no |
47 |
|
|
checksum kept) or a runtime error. |
48 |
|
|
|
49 |
|
|
=head1 SEE ALSO |
50 |
|
|
|
51 |
|
|
Other Compress::* modules, especially Compress::LZV1 (an older, less |
52 |
|
|
speedy module that guarentees only 1 byte overhead worst case) and |
53 |
|
|
Compress::Zlib. |
54 |
|
|
|
55 |
|
|
http://liblzf.plan9.de/ |
56 |
|
|
|
57 |
|
|
=head1 AUTHOR |
58 |
|
|
|
59 |
|
|
This perl extension and the underlying liblzf were written by Marc Lehmann |
60 |
|
|
<pcg@goof.com> (See also http://liblzf.plan9.de/). |
61 |
|
|
|
62 |
|
|
=head1 BUGS |
63 |
|
|
|
64 |
|
|
=cut |
65 |
|
|
|
66 |
|
|
package Compress::LZF; |
67 |
|
|
|
68 |
|
|
require Exporter; |
69 |
|
|
require DynaLoader; |
70 |
|
|
|
71 |
|
|
$VERSION = 0.1; |
72 |
|
|
@ISA = qw/Exporter DynaLoader/; |
73 |
|
|
%EXPORT_TAGS = ( |
74 |
|
|
freeze => [qw(sfreeze sfreeze_cr sfreeze_c sthaw)], |
75 |
|
|
compress => [qw(compress decompress)], |
76 |
|
|
); |
77 |
|
|
|
78 |
|
|
Exporter::export_tags('compress'); |
79 |
|
|
Exporter::export_ok_tags('freeze'); |
80 |
|
|
|
81 |
|
|
bootstrap Compress::LZF $VERSION; |
82 |
|
|
|
83 |
|
|
1; |
84 |
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|