Data::Serializer:: - Modules that serialize data structures
use Data::Serializer; $obj = Data::Serializer->new(); $obj = Data::Serializer->new( serializer => 'Storable', digester => 'MD5', cipher => 'DES', secret => 'my secret', compress => 1, ); $serialized = $obj->serialize({a => [1,2,3],b => 5}); $deserialized = $obj->deserialize($serialized); print "$deserialized->{b}\n";
Provides a unified interface to the various serializing modules currently available. Adds the functionality of both compression and encryption.
$obj = Data::Serializer->new(); $obj = Data::Serializer->new( serializer => 'Data::Dumper', digester => 'SHA1', cipher => 'Blowfish', secret => undef, portable => '1', compress => '0', serializer_token => '1', options => {}, );
new is the constructor object for Data::Serializer objects.
The default serializer is Data::Dumper
Data::Dumper
The default digester is SHA1
SHA1
The default cipher is Blowfish
Blowfish
The default secret is undef
undef
The default portable is 1
1
The default encoding is hex
hex
The default compress is 0
0
The default serializer_token is 1
The default options is {} (pass nothing on to serializer)
{}
$serialized = $obj->serialize({a => [1,2,3],b => 5});
Serializes the reference specified.
Will compress if compress is a true value.
Will encrypt if secret is defined.
$deserialized = $obj->deserialize($serialized);
Reverses the process of serialization and returns a copy of the original serialized reference.
$serialized = $obj->freeze({a => [1,2,3],b => 5});
$deserialized = $obj->thaw($serialized);
$obj->secret('mysecret');
Changes setting of secret for the Data::Serializer object. Can also be set in the constructor. If specified than the object will utilize encryption.
Uses encoding method to ascii armor serialized data
Aids in the portability of serialized data.
Compresses serialized data. Default is not to use it.
Currently have 6 supported serializers: Storable, FreezeThaw, Data::Denter, Config::General, YAML and Data::Dumper. Default is to use Data::Dumper.
Each serializer has its own caveat's about usage especially when dealing with cyclical data structures or CODE references. Please see the appropriate documentation in those modules for further information.
Utilizes Crypt::CBC and can support any cipher method that it supports.
Uses Digest so can support any digesting method that it supports. Digesting function is used internally by the encryption routine as part of data verification.
Encodes data structure in ascii friendly manner. Currently the only valid options are hex, or b64.
The b64 option uses Base64 encoding provided by MIME::Base64, but strips out newlines.
Data::Serializer prepends a token that identifies what was used to process its data. This is used internally to allow runtime determination of how to extract Serialized data. Disabling this feature is not recommended.
Currently is only supported by Config::General.
my $obj = Data::Serializer->new(serializer=>'Config::General', options => { -LowerCaseNames => 1, -UseApacheInclude => 1, -MergeDuplicateBlocks => 1, -AutoTrue => 1, -InterPolateVars => 1 }, ) or die "$!\n";
Data::Serializer is aware of Tie::Transient. What this means is that you use Tie::Transient as normal, and when your object is serialized, the transient components will be automatically removed for you.
Tie::Transient is not on CPAN, and doesn't look like it ever will be. With the advent of attributes from 5.8 this feature should probably be deprecated anyway.
If you would like to use Tie::Transient you can download it directly from Brian's site here: http://www.maz.org/perl/Tie-Transient-0.05.tar.gz
With perl attributes in 5.8, this should probably be deprecated.
Neil Neely <neil@frii.net>.
Copyright (c) 2001-2004 Front Range Internet, Inc.
Copyright (c) 2001-2004 Neil Neely. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Gurusamy Sarathy and Raphael Manfredi for writing MLDBM, the module which inspired the creation of Data::Serializer.
And a thanks to all of you who have provided the feedback that has improved this module over the years.
In particular I'd like to thank Florian Helmberger, for the numerous suggestions and bug fixes.
perl(1), Data::Dumper(3), Data::Denter(3), Storable(3), FreezeThaw(3), Config::General(3), YAML(3), MLDBM(3), Tie::Transient(3), Compress::Zlib(3), Digest(3), Crypt(3), MIME::Base64(3).
To install Data::Serializer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Serializer
CPAN shell
perl -MCPAN -e shell install Data::Serializer
For more information on module installation, please visit the detailed CPAN module installation guide.