Data::...er::Raw(3pm)
π Data::...er::Raw(3pm) β the raw, unfiltered, no-makeup serialization interface π
okay bestie, listen. this is Data::Serializer::Raw, from the User Contributed Perl Documentation, and it is exactly what it says on the tin: a unified raw interface to perl serializers. no glow-up, no filter, no extra steps. just vibes and bytes. β¨
β¨ NAME β¨
Data::Serializer::Raw β provides unified raw interface to perl serializers π¦
β¨ SYNOPSIS β¨
use Data::Serializer::Raw;
$obj = Data::Serializer::Raw->new();
$obj = Data::Serializer::Raw->new(serializer => 'Storable');
$serialized = $obj->serialize({a => [1,2,3],b => 5});
$deserialized = $obj->deserialize($serialized);
print "$deserialized->{b}\n";
β¨ DESCRIPTION β¨
so basically? it gives you one unified interface to all the various serializing modules that are out there rn. that's the whole gig. π
and when we say raw, we mean RAW. this is a straight pass through to the underlying serializer, and nothing else is done. no encoding. no encryption. no compression. nothing. it's giving minimalist. it's giving lean. π
β¨ EXAMPLES β¨
pls go look at Data::Serializer::Cookbook(3) for the good stuff, bestie π
β¨ METHODS β¨
πΈ new β constructor πΈ
$obj = Data::Serializer::Raw->new();
$obj = Data::Serializer::Raw->new(
serializer => 'Data::Dumper',
options => {},
);
new is the constructor object for Data::Serializer::Raw objects. it's literally the main character of this whole page.
- the default serializer is
"Data::Dumper"β no cap - the default options is
"{}"(which means: pass nothing on to the serializer, we're keeping it lowkey)
πΈ serialize β serialize reference πΈ
$serialized = $obj->serialize({a => [1,2,3],b => 5});
straight pass through to the underlying serializer, nothing else done. no encoding, encryption, compression, etc. what you put in is what the serializer gets, periodt. π«
πΈ deserialize β deserialize reference πΈ
$deserialized = $obj->deserialize($serialized);
again bestie: straight pass through to the underlying serializer, nothing else done. (no encoding, encryption, compression, etc) it's symmetric, it's iconic, it's the reverse of the thing above. π
πΈ serializer β change the serializer πΈ
rn it supports the following serializers, and yes we're listing every single one, no skipping:
Bencode(3)Convert::Bencode(3)Convert::Bencode_XS(3)Config::General(3)Data::Denter(3)Data::Dumper(3)Data::Taxi(3)FreezeThaw(3)JSON(3)JSON::Syck(3)PHP::Serialization(3)Storable(3)XML::Dumper(3)XML::Simple(3)YAML(3)YAML::Syck(3)
default is to use Data::Dumper. that's the comfort pick. π«Ά
β οΈ okay important!! each serializer has its own caveats about usage, especially when you're dealing with cyclical data structures or CODE references. like, genuinely, go read the appropriate documentation in those modules for further information before you come crying to me. π
πΈ options β pass options through to underlying serializer πΈ
currently this is only supported by Config::General(3) and XML::Dumper(3). that's it. everyone else, no options for you. π
my $obj = Data::Serializer::Raw->new(serializer => 'Config::General',
options => {
-LowerCaseNames => 1,
-UseApacheInclude => 1,
-MergeDuplicateBlocks => 1,
-AutoTrue => 1,
-InterPolateVars => 1
},
) or die "$!\n";
or
my $obj = Data::Serializer::Raw->new(serializer => 'XML::Dumper',
options => { dtd => 1, }
) or die "$!\n";
πΈ store β serialize data and write it to a file (or file handle) πΈ
$obj->store({a => [1,2,3],b => 5},$file, [$mode, $perm]);
or
$obj->store({a => [1,2,3],b => 5},$fh);
it serializes the reference you specified (using the serialize method, obvi) and writes it out to the specified file or filehandle. π
if you give it a file path, you may also specify an optional mode and permission as the next two arguments. see IO::File for examples, bestie.
π¨ trips an exception if it is unable to write to the specified file. so like, be normal about your permissions.
πΈ retrieve β read data from file (or file handle) and return it after deserialization πΈ
my $ref = $obj->retrieve($file);
or
my $ref = $obj->retrieve($fh);
reads the first line of the supplied file or filehandle and returns it deserialized. first line. that's the deal. π
β¨ AUTHOR β¨
Neil Neely <neil@neely.cx>. π
http://neil-neely.blogspot.com/
β¨ BUGS β¨
please report all bugs here, and fr fr do it:
http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Serializer
β¨ COPYRIGHT AND LICENSE β¨
Copyright (c) 2011 Neil Neely. All rights reserved.
this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.2 or, at your option, any later version of Perl 5 you may have available.
see http://www.perl.com/language/misc/Artistic.html
β¨ ACKNOWLEDGEMENTS β¨
shoutout to Peter Makholm, who took the time to profile Data::Serializer(3) and pointed out the value of having a very lean implementation that minimized overhead and just used the raw underlying serializers. that's the whole ethos of this module and honestly? he ate. π
β¨ SEE ALSO β¨
perl(1), Data::Serializer(3). π¦
and that's the page!! this one's from perl v5.36.0, dated 2022-10-22, and it lives under the name Data::...er::Raw(3pm) β mwah, go serialize something raw, bestie π πβ¨
π¦ where this page comes from
- debian bookworm: libdata-serializer-perl 0.65-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdata-serializer-perl 0.65-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdata-serializer-perl 0.65-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdata-serializer-perl 0.65-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdata-serializer-perl 0.65-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms