--- Compress-LZF/LZF.pm 2001/09/27 18:36:34 1.1 +++ Compress-LZF/LZF.pm 2002/09/05 04:44:55 1.10 @@ -15,8 +15,8 @@ # import sfreeze, sfreeze_cref and sfreeze_c use Compress::LZF ':freeze'; - $compressed = sfreeze_c [4,5,6]; - $original_data = sthaw $compressed; + $serialized = sfreeze_c [4,5,6]; + $original_data = sthaw $serialized; =head1 DESCRIPTION @@ -46,6 +46,49 @@ data. Decompression errors can result in either broken data (there is no checksum kept) or a runtime error. +=head2 $serialized = sfreeze $value (simplified freeze) + +Often there is the need to serialize data into a string. This function does that, by using the Storable +module. It does the following transforms: + + undef (the perl undefined value) + => a special cookie (undef'ness is being preserved) + IV, NV, PV (i.e. a _plain_ perl scalar): + => stays as is when it contains normal text/numbers + => gets serialized into a string + RV, undef, other funny objects (magical ones for example): + => data structure is freeze'd into a string. + +That is, it tries to leave "normal", human-readable data untouched but +still serializes complex data structures into strings. The idea is to keep +readability as high as possible, and in cases readability can't be helped +anyways, it tries to compress the string. + +The C functions will enlarge the original data one byte at most +and will only load the Storable method when neccessary. + +=head2 $serialized = sfreeze_c $value (sfreeze and compress) + +Similar to C, but always tries to Compress the resulting +string. This still leaves most small objects (most numbers) untouched. + +=head2 $serialized = sfreeze_cr $value (sfreeze and compress references) + +Similar to C, but tries to Compress the resulting string +unless it's a "simple" string. References for example are not "simple" and +as such are being compressed. + +=head2 $original_data = sthaw $serialized + +Recreate the original object from it's serialized representation. This +function automatically detects all the different sfreeze formats. + +=head2 Compress::LZF::set_serializer $package, $freeze, $store + +Set the serialize module and functions to use. The default is "Storable", +"Storable::mstore" and "Storable::mretrieve", which should be fine for +most purposes. + =head1 SEE ALSO Other Compress::* modules, especially Compress::LZV1 (an older, less @@ -68,7 +111,7 @@ require Exporter; require DynaLoader; -$VERSION = 0.1; +$VERSION = 0.1044; @ISA = qw/Exporter DynaLoader/; %EXPORT_TAGS = ( freeze => [qw(sfreeze sfreeze_cr sfreeze_c sthaw)],