1LZF(3)                User Contributed Perl Documentation               LZF(3)
2
3
4

NAME

6       Compress::LZF - extremely light-weight Lempel-Ziv-Free compression
7

SYNOPSIS

9          # import compress/decompress functions
10          use Compress::LZF;
11          # the same as above
12          use Compress::LZF ':compress';
13
14          $compressed = compress $uncompressed_data;
15          $original_data = decompress $compressed;
16
17          # import sfreeze, sfreeze_cref and sfreeze_c
18          use Compress::LZF ':freeze';
19
20          $serialized = sfreeze_c [4,5,6];
21          $original_data = sthaw $serialized;
22

DESCRIPTION

24       LZF is an extremely fast (not that much slower than a pure memcpy)
25       compression algorithm. It is ideal for applications where you want to
26       save some space but not at the cost of speed. It is ideal for
27       repetitive data as well. The module is self-contained and very small
28       (no large library to be pulled in). It is also free, so there should be
29       no problems incorporating this module into commercial programs.
30
31       I have no idea wether any patents in any countries apply to this
32       algorithm, but at the moment it is believed that it is free from any
33       patents.
34

FUNCTIONS

36       $compressed = compress $uncompressed
37           Try to compress the given string as quickly and as much as
38           possible. In the worst case, the string can enlarge by 1 byte, but
39           that should be the absolute exception. You can expect a 45%
40           compression ratio on large, binary strings.
41
42       $decompressed = decompress $compressed
43           Uncompress the string (compressed by "compress") and return the
44           original data. Decompression errors can result in either broken
45           data (there is no checksum kept) or a runtime error.
46
47       $serialized = sfreeze $value (simplified freeze)
48           Often there is the need to serialize data into a string. This
49           function does that, by using the Storable module. It does the
50           following transforms:
51
52             undef (the perl undefined value)
53                => a special cookie (undef'ness is being preserved)
54             IV, NV, PV (i.e. a _plain_ perl scalar):
55                => stays as is when it contains normal text/numbers
56                => gets serialized into a string
57             RV, undef, other funny objects (magical ones for example):
58                => data structure is freeze'd into a string.
59
60           That is, it tries to leave "normal", human-readable data untouched
61           but still serializes complex data structures into strings. The idea
62           is to keep readability as high as possible, and in cases
63           readability can't be helped anyways, it tries to compress the
64           string.
65
66           The "sfreeze" functions will enlarge the original data one byte at
67           most and will only load the Storable method when neccessary.
68
69       $serialized = sfreeze_c $value (sfreeze and compress)
70           Similar to "sfreeze", but always tries to "c"ompress the resulting
71           string. This still leaves most small objects (most numbers)
72           untouched.
73
74           The "sfreeze_c" function uses a different algorithm that is slower
75           but usually achieves better compression.
76
77       $serialized = sfreeze_cr $value (sfreeze and compress references)
78           Similar to "sfreeze", but tries to "c"ompress the resulting string
79           unless it's a "simple" string. References for example are not
80           "simple" and as such are being compressed.
81
82       $original_data = sthaw $serialized
83           Recreate the original object from it's serialized representation.
84           This function automatically detects all the different sfreeze
85           formats.
86
87       Compress::LZF::set_serializer $package, $freeze, $thaw
88           Set the serialize module and functions to use. The default is
89           "Storable", "Storable::net_mstore" and "Storable::mretrieve", which
90           should be fine for most purposes.
91

SUPPORT FOR THE PERL MULTICORE SPECIFICATION

93       This module supports the perl multicore specification
94       (<http://perlmulticore.schmorp.de/>) for all compression (> 2000
95       octets) and decompression (> 4000 octets) functions.
96

NO SUPPORT FOR BEST METHODS

98       "compress_best" and other _best subroutines were removed because
99       liblzf-3.6 does not yet support them. See
100       <https://bugzilla.redhat.com/show_bug.cgi?id=1268333>.
101

SEE ALSO

103       Other Compress::* modules, especially Compress::LZV1 (an older, less
104       speedy module that guarentees only 1 byte overhead worst case) and
105       Compress::Zlib.
106
107       http://liblzf.plan9.de/
108

AUTHOR

110       This perl extension and the underlying liblzf were written by Marc
111       Lehmann <schmorp@schmorp.de> (See also http://liblzf.plan9.de/).
112

BUGS

114perl v5.36.0                      2022-07-22                            LZF(3)
Impressum