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.32 by root, Mon Dec 29 08:46:40 2008 UTC vs.
Revision 1.33 by root, Sun Aug 25 18:13:26 2013 UTC

31algorithm, but at the moment it is believed that it is free from any 31algorithm, but at the moment it is believed that it is free from any
32patents. 32patents.
33 33
34=head1 FUNCTIONS 34=head1 FUNCTIONS
35 35
36=over 4
37
36=head2 $compressed = compress $uncompressed 38=item $compressed = compress $uncompressed
39
40=item $compressed = compress_best $uncompressed
37 41
38Try to compress the given string as quickly and as much as possible. In 42Try to compress the given string as quickly and as much as possible. In
39the worst case, the string can enlarge by 1 byte, but that should be the 43the worst case, the string can enlarge by 1 byte, but that should be the
40absolute exception. You can expect a 45% compression ratio on large, 44absolute exception. You can expect a 45% compression ratio on large,
41binary strings. 45binary strings.
42 46
47The C<compress_best> function uses a different algorithm that is slower
48but usually achieves better compression.
49
43=head2 $decompressed = decompress $compressed 50=item $decompressed = decompress $compressed
44 51
45Uncompress the string (compressed by C<compress>) and return the original 52Uncompress the string (compressed by C<compress>) and return the original
46data. Decompression errors can result in either broken data (there is no 53data. Decompression errors can result in either broken data (there is no
47checksum kept) or a runtime error. 54checksum kept) or a runtime error.
48 55
49=head2 $serialized = sfreeze $value (simplified freeze) 56=item $serialized = sfreeze $value (simplified freeze)
57
58=item $serialized = sfreeze_best $value
50 59
51Often there is the need to serialize data into a string. This function does that, by using the Storable 60Often there is the need to serialize data into a string. This function does that, by using the Storable
52module. It does the following transforms: 61module. It does the following transforms:
53 62
54 undef (the perl undefined value) 63 undef (the perl undefined value)
65anyways, it tries to compress the string. 74anyways, it tries to compress the string.
66 75
67The C<sfreeze> functions will enlarge the original data one byte at most 76The C<sfreeze> functions will enlarge the original data one byte at most
68and will only load the Storable method when neccessary. 77and will only load the Storable method when neccessary.
69 78
79The C<sfreeze_best> function uses a different algorithm that is slower
80but usually achieves better compression.
81
70=head2 $serialized = sfreeze_c $value (sfreeze and compress) 82=item $serialized = sfreeze_c $value (sfreeze and compress)
83
84=item $serialized = sfreeze_c_best $value
71 85
72Similar to C<sfreeze>, but always tries to C<c>ompress the resulting 86Similar to C<sfreeze>, but always tries to C<c>ompress the resulting
73string. This still leaves most small objects (most numbers) untouched. 87string. This still leaves most small objects (most numbers) untouched.
74 88
89The C<sfreeze_c> function uses a different algorithm that is slower
90but usually achieves better compression.
91
75=head2 $serialized = sfreeze_cr $value (sfreeze and compress references) 92=item $serialized = sfreeze_cr $value (sfreeze and compress references)
93
94=item $serialized = sfreeze_cr_best $value
76 95
77Similar to C<sfreeze>, but tries to C<c>ompress the resulting string 96Similar 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 97unless it's a "simple" string. References for example are not "simple" and
79as such are being compressed. 98as such are being compressed.
80 99
100The C<sfreeze_cr_best> function uses a different algorithm that is slower
101but usually achieves better compression.
102
81=head2 $original_data = sthaw $serialized 103=item $original_data = sthaw $serialized
82 104
83Recreate the original object from it's serialized representation. This 105Recreate the original object from it's serialized representation. This
84function automatically detects all the different sfreeze formats. 106function automatically detects all the different sfreeze formats.
85 107
86=head2 Compress::LZF::set_serializer $package, $freeze, $thaw 108=item Compress::LZF::set_serializer $package, $freeze, $thaw
87 109
88Set the serialize module and functions to use. The default is "Storable", 110Set the serialize module and functions to use. The default is "Storable",
89"Storable::net_mstore" and "Storable::mretrieve", which should be fine for 111"Storable::net_mstore" and "Storable::mretrieve", which should be fine for
90most purposes. 112most purposes.
113
114=back
91 115
92=head1 SEE ALSO 116=head1 SEE ALSO
93 117
94Other Compress::* modules, especially Compress::LZV1 (an older, less 118Other Compress::* modules, especially Compress::LZV1 (an older, less
95speedy module that guarentees only 1 byte overhead worst case) and 119speedy module that guarentees only 1 byte overhead worst case) and
109package Compress::LZF; 133package Compress::LZF;
110 134
111require Exporter; 135require Exporter;
112require DynaLoader; 136require DynaLoader;
113 137
114$VERSION = '3.43'; 138$VERSION = '3.7';
115@ISA = qw/Exporter DynaLoader/; 139@ISA = qw/Exporter DynaLoader/;
116%EXPORT_TAGS = ( 140%EXPORT_TAGS = (
117 freeze => [qw(sfreeze sfreeze_cr sfreeze_c sthaw)], 141 freeze => [qw(sfreeze sfreeze_best sfreeze_cr sfreeze_cr_best sfreeze_c sfreeze_c_best sthaw)],
118 compress => [qw(compress decompress)], 142 compress => [qw(compress compress_best decompress)],
119); 143);
120 144
121Exporter::export_tags('compress'); 145Exporter::export_tags('compress');
122Exporter::export_ok_tags('freeze'); 146Exporter::export_ok_tags('freeze');
123 147

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines