1Data::Serializer::Raw(3U)ser Contributed Perl DocumentatiDoanta::Serializer::Raw(3)
2
3
4

NAME

6       Data::Serializer::Raw - Provides unified raw interface to perl
7       serializers
8

SYNOPSIS

10         use Data::Serializer::Raw;
11
12         $obj = Data::Serializer::Raw->new();
13
14         $obj = Data::Serializer::Raw->new(serializer => 'Storable');
15
16         $serialized = $obj->serialize({a => [1,2,3],b => 5});
17         $deserialized = $obj->deserialize($serialized);
18
19         print "$deserialized->{b}\n";
20

DESCRIPTION

22       Provides a unified interface to the various serializing modules
23       currently available.
24
25       This is a straight pass through to the underlying serializer, nothing
26       else is done. (no encoding, encryption, compression, etc)
27

EXAMPLES

29       Please see Data::Serializer::Cookbook(3)
30

METHODS

32       new - constructor
33             $obj = Data::Serializer::Raw->new();
34
35
36             $obj = Data::Serializer::Raw->new(
37                                    serializer => 'Data::Dumper',
38                                      options  => {},
39                                   );
40
41           new is the constructor object for Data::Serializer::Raw objects.
42
43           •   The default serializer is "Data::Dumper"
44
45           •   The default options is "{}" (pass nothing on to serializer)
46
47       serialize - serialize reference
48             $serialized = $obj->serialize({a => [1,2,3],b => 5});
49
50           This is a straight pass through to the underlying serializer,
51           nothing else is done. (no encoding, encryption, compression, etc)
52
53       deserialize - deserialize reference
54             $deserialized = $obj->deserialize($serialized);
55
56           This is a straight pass through to the underlying serializer,
57           nothing else is done. (no encoding, encryption, compression, etc)
58
59       serializer - change the serializer
60           Currently supports the following serializers:
61
62           Bencode(3)
63           Convert::Bencode(3)
64           Convert::Bencode_XS(3)
65           Config::General(3)
66           Data::Denter(3)
67           Data::Dumper(3)
68           Data::Taxi(3)
69           FreezeThaw(3)
70           JSON(3)
71           JSON::Syck(3)
72           PHP::Serialization(3)
73           Storable(3)
74           XML::Dumper(3)
75           XML::Simple(3)
76           YAML(3)
77           YAML::Syck(3)
78
79           Default is to use Data::Dumper.
80
81           Each serializer has its own caveat's about usage especially when
82           dealing with cyclical data structures or CODE references.  Please
83           see the appropriate documentation in those modules for further
84           information.
85
86       options - pass options through to underlying serializer
87           Currently is only supported by Config::General(3), and
88           XML::Dumper(3).
89
90             my $obj = Data::Serializer::Raw->new(serializer => 'Config::General',
91                                             options    => {
92                                                        -LowerCaseNames       => 1,
93                                                        -UseApacheInclude     => 1,
94                                                        -MergeDuplicateBlocks => 1,
95                                                        -AutoTrue             => 1,
96                                                        -InterPolateVars      => 1
97                                                           },
98                                                         ) or die "$!\n";
99
100             or
101
102             my $obj = Data::Serializer::Raw->new(serializer => 'XML::Dumper',
103                                             options    => { dtd => 1, }
104                                             ) or die "$!\n";
105
106       store - serialize data and write it to a file (or file handle)
107             $obj->store({a => [1,2,3],b => 5},$file, [$mode, $perm]);
108
109             or
110
111             $obj->store({a => [1,2,3],b => 5},$fh);
112
113           Serializes the reference specified using the serialize method and
114           writes it out to the specified file or filehandle.
115
116           If a file path is specified you may specify an optional mode and
117           permission as the next two arguments.  See IO::File for examples.
118
119           Trips an exception if it is unable to write to the specified file.
120
121       retrieve - read data from file (or file handle) and return it after
122       deserialization
123             my $ref = $obj->retrieve($file);
124
125             or
126
127             my $ref = $obj->retrieve($fh);
128
129           Reads first line of supplied file or filehandle and returns it
130           deserialized.
131

AUTHOR

133       Neil Neely <neil@neely.cx>.
134
135       http://neil-neely.blogspot.com/
136

BUGS

138       Please report all bugs here:
139
140       http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Serializer
141
143       Copyright (c) 2011 Neil Neely.  All rights reserved.
144
145       This library is free software; you can redistribute it and/or modify it
146       under the same terms as Perl itself, either Perl version 5.8.2 or, at
147       your option, any later version of Perl 5 you may have available.
148
149       See http://www.perl.com/language/misc/Artistic.html
150

ACKNOWLEDGEMENTS

152       Peter Makholm took the time to profile Data::Serializer(3) and pointed
153       out the value of having a very lean implementation that minimized
154       overhead and just used the raw underlying serializers.
155

SEE ALSO

157       perl(1), Data::Serializer(3).
158
159
160
161perl v5.32.1                      2021-01-27          Data::Serializer::Raw(3)
Impressum