1 | =head1 NAME |
1 | =head1 NAME |
2 | |
2 | |
3 | Compress::LZF - extremely leight-weight Lev-Zimpel-Free compression |
3 | Compress::LZF - extremely light-weight Lempel-Ziv-Free compression |
4 | |
4 | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | # import compress/decompress functions |
7 | # import compress/decompress functions |
8 | use Compress::LZF; |
8 | use Compress::LZF; |
… | |
… | |
23 | LZF is an extremely fast (not that much slower than a pure memcpy) |
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 |
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 |
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 |
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 |
27 | library to be pulled in). It is also free, so there should be no problems |
28 | incoporating this module into commercial programs. |
28 | incorporating this module into commercial programs. |
29 | |
29 | |
30 | I have no idea wether any patents in any countries apply to this |
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 |
31 | algorithm, but at the moment it is believed that it is free from any |
32 | patents. |
32 | patents. |
33 | |
33 | |
… | |
… | |
49 | =head2 $serialized = sfreeze $value (simplified freeze) |
49 | =head2 $serialized = sfreeze $value (simplified freeze) |
50 | |
50 | |
51 | Often there is the need to serialize data into a string. This function does that, by using the Storable |
51 | Often there is the need to serialize data into a string. This function does that, by using the Storable |
52 | module. It does the following transforms: |
52 | module. It does the following transforms: |
53 | |
53 | |
|
|
54 | undef (the perl undefined value) |
|
|
55 | => a special cookie (undef'ness is being preserved) |
54 | IV, NV, PV (i.e. a _plain_ perl scalar): |
56 | IV, NV, PV (i.e. a _plain_ perl scalar): |
55 | => stays as is when it contains normal text/numbers |
57 | => stays as is when it contains normal text/numbers |
56 | => gets serialized into a string |
58 | => gets serialized into a string |
57 | RV, undef, other funny objects (magical ones for example): |
59 | RV, undef, other funny objects (magical ones for example): |
58 | => data structure is freeze'd into a string. |
60 | => data structure is freeze'd into a string. |
59 | |
61 | |
60 | That is, it tries to leave "normal", human-readable data untouched but |
62 | That is, it tries to leave "normal", human-readable data untouched but |
61 | still serializes complex data structures into strings. |
63 | still serializes complex data structures into strings. The idea is to keep |
62 | |
64 | readability as high as possible, and in cases readability can't be helped |
63 | The idea of all these C<sfreeze> functions is to keep readability as high |
65 | anyways, it tries to compress the string. |
64 | as possible, and in cases readability can't be helped anyways, it tries to |
|
|
65 | compress the string. |
|
|
66 | |
66 | |
67 | The C<sfreeze> functions will enlarge the original data one byte at most |
67 | The C<sfreeze> functions will enlarge the original data one byte at most |
68 | and will only load the Storable method when neccessary. |
68 | and will only load the Storable method when neccessary. |
69 | |
69 | |
70 | =head2 $serialized = sfreeze_c $value (sfreeze and compress) |
70 | =head2 $serialized = sfreeze_c $value (sfreeze and compress) |
… | |
… | |
81 | =head2 $original_data = sthaw $serialized |
81 | =head2 $original_data = sthaw $serialized |
82 | |
82 | |
83 | Recreate the original object from it's serialized representation. This |
83 | Recreate the original object from it's serialized representation. This |
84 | function automatically detects all the different sfreeze formats. |
84 | function automatically detects all the different sfreeze formats. |
85 | |
85 | |
|
|
86 | =head2 Compress::LZF::set_serializer $package, $freeze, $thaw |
|
|
87 | |
|
|
88 | Set the serialize module and functions to use. The default is "Storable", |
|
|
89 | "Storable::net_mstore" and "Storable::mretrieve", which should be fine for |
|
|
90 | most purposes. |
|
|
91 | |
86 | =head1 SEE ALSO |
92 | =head1 SEE ALSO |
87 | |
93 | |
88 | Other Compress::* modules, especially Compress::LZV1 (an older, less |
94 | Other Compress::* modules, especially Compress::LZV1 (an older, less |
89 | speedy module that guarentees only 1 byte overhead worst case) and |
95 | speedy module that guarentees only 1 byte overhead worst case) and |
90 | Compress::Zlib. |
96 | Compress::Zlib. |
… | |
… | |
92 | http://liblzf.plan9.de/ |
98 | http://liblzf.plan9.de/ |
93 | |
99 | |
94 | =head1 AUTHOR |
100 | =head1 AUTHOR |
95 | |
101 | |
96 | This perl extension and the underlying liblzf were written by Marc Lehmann |
102 | This perl extension and the underlying liblzf were written by Marc Lehmann |
97 | <pcg@goof.com> (See also http://liblzf.plan9.de/). |
103 | <schmorp@schmorp.de> (See also http://liblzf.plan9.de/). |
98 | |
104 | |
99 | =head1 BUGS |
105 | =head1 BUGS |
100 | |
106 | |
101 | =cut |
107 | =cut |
102 | |
108 | |
103 | package Compress::LZF; |
109 | package Compress::LZF; |
104 | |
110 | |
105 | require Exporter; |
111 | require Exporter; |
106 | require DynaLoader; |
112 | require DynaLoader; |
107 | |
113 | |
108 | $VERSION = 0.1; |
114 | $VERSION = '1.8'; |
109 | @ISA = qw/Exporter DynaLoader/; |
115 | @ISA = qw/Exporter DynaLoader/; |
110 | %EXPORT_TAGS = ( |
116 | %EXPORT_TAGS = ( |
111 | freeze => [qw(sfreeze sfreeze_cr sfreeze_c sthaw)], |
117 | freeze => [qw(sfreeze sfreeze_cr sfreeze_c sthaw)], |
112 | compress => [qw(compress decompress)], |
118 | compress => [qw(compress decompress)], |
113 | ); |
119 | ); |