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.5 by root, Wed Feb 27 20:51:21 2002 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
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 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 undef (the perl undefined value)
55 => a special cookie (undef'ness is being preserved)
56 IV, NV, PV (i.e. a _plain_ perl scalar):
57 => stays as is when it contains normal text/numbers
58 => gets serialized into a string
59 RV, undef, other funny objects (magical ones for example):
60 => data structure is freeze'd into a string.
61
62That is, it tries to leave "normal", human-readable data untouched but
63still serializes complex data structures into strings. The idea is to keep
64readability as high as possible, and in cases readability can't be helped
65anyways, it tries to compress 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.
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
53Compress::Zlib. 90Compress::Zlib.
66package Compress::LZF; 103package Compress::LZF;
67 104
68require Exporter; 105require Exporter;
69require DynaLoader; 106require DynaLoader;
70 107
71$VERSION = 0.1; 108$VERSION = 0.102;
72@ISA = qw/Exporter DynaLoader/; 109@ISA = qw/Exporter DynaLoader/;
73%EXPORT_TAGS = ( 110%EXPORT_TAGS = (
74 freeze => [qw(sfreeze sfreeze_cr sfreeze_c sthaw)], 111 freeze => [qw(sfreeze sfreeze_cr sfreeze_c sthaw)],
75 compress => [qw(compress decompress)], 112 compress => [qw(compress decompress)],
76); 113);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines