ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Compress-LZF/LZF.pm
(Generate patch)

Comparing Compress-LZF/LZF.pm (file contents):
Revision 1.1 by root, Thu Sep 27 18:36:34 2001 UTC vs.
Revision 1.2 by root, Thu Sep 27 19:51:24 2001 UTC

13 $original_data = decompress $compressed; 13 $original_data = decompress $compressed;
14 14
15 # import sfreeze, sfreeze_cref and sfreeze_c 15 # import sfreeze, sfreeze_cref and sfreeze_c
16 use Compress::LZF ':freeze'; 16 use Compress::LZF ':freeze';
17 17
18 $compressed = sfreeze_c [4,5,6]; 18 $serialized = sfreeze_c [4,5,6];
19 $original_data = sthaw $compressed; 19 $original_data = sthaw $serialized;
20 20
21=head1 DESCRIPTION 21=head1 DESCRIPTION
22 22
23LZF is an extremely fast (not that much slower than a pure memcpy) 23LZF is an extremely fast (not that much slower than a pure memcpy)
24compression algorithm. It is ideal for applications where you want to save 24compression algorithm. It is ideal for applications where you want to save
43=head2 $decompressed = decompress $compressed 43=head2 $decompressed = decompress $compressed
44 44
45Uncompress the string (compressed by C<compress>) and return the original 45Uncompress the string (compressed by C<compress>) and return the original
46data. Decompression errors can result in either broken data (there is no 46data. Decompression errors can result in either broken data (there is no
47checksum kept) or a runtime error. 47checksum kept) or a runtime error.
48
49=head2 $serialized = sfreeze $value (simplified freeze)
50
51Often there is the need to serialize data into a string. This function does that, by using the Storable
52module. It does the following transforms:
53
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
60That is, it tries to leave "normal", human-readable data untouched but
61still serializes complex data structures into strings.
62
63The idea of all these C<sfreeze> functions is to keep readability as high
64as possible, and in cases readability can't be helped anyways, it tries to
65compress the string.
66
67The C<sfreeze> functions will enlarge the original data one byte at most
68and will only load the Storable method when neccessary.
69
70=head2 $serialized = sfreeze_c $value (sfreeze and compress)
71
72Similar to C<sfreeze>, but always tries to C<c>ompress the resulting
73string. This still leaves most small objects (most numbers) untouched.
74
75=head2 $serialized = sfreeze_cr $value (sfreeze and compress references)
76
77Similar to C<sfreeze>, but tries to C<c>ompress the resulting string
78unless it's a "simple" string. References for example are not "simple" and
79as such are being compressed.
80
81=head2 $original_data = sthaw $serialized
82
83Recreate the original object from it's serialized representation. This
84function automatically detects all the different sfreeze formats.
48 85
49=head1 SEE ALSO 86=head1 SEE ALSO
50 87
51Other Compress::* modules, especially Compress::LZV1 (an older, less 88Other Compress::* modules, especially Compress::LZV1 (an older, less
52speedy module that guarentees only 1 byte overhead worst case) and 89speedy module that guarentees only 1 byte overhead worst case) and

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines