Config::INI::Serializer - Round-trip INI serializer for nested data
require Config::INI::Serializer; my $ini = Config::INI::Serializer->new; my $data = { an => 'arbitrary', collection => [ 'of', 'data', ], of => { arbitrary => 'depth', }, }; my $ini_text = $ini->serialize($data);
$data = $ini->deserialize($ini_text);
This library is the carved-out INI-file handling from App::Context, namely the essential functions from App:Serializer::Ini and App::Reference.
OH NOES - JET ANOTHR INI MOTULE! - but this one turned out to work better for INI-like nested data serialization where compatibility with other modules is not as important. It is used in the dpath utility.
ACHTUNG! The "round-trip ability" belongs to the data written by the module itself. It does not perfectly keep foreign data structures. Carefully read the CAVEATS section below.
CAVEATS
Constructor.
$serializer = Config::INI::Serializer->new;
$serializer = Config::INI::Serializer->new; $inidata = $serializer->serialize($data);
$serializer = Config::INI::Serializer->new; $data = $serializer->deserialize($inidata); print $serializer->dump($data), "\n";
It can read most of the other INI formats, but writing is done a bit special to handle nested data.
So using this module is kind of a "one-way ticket to slammertown with no return ticket" aka. vendor lock-in.
Array indexes are expressed like numbered hash keys:
[list.0] ... [list.1] ... [list.2] ... [list.10]
which, when re-read, actually become hash keys as there is no more distinction after that. Besides losing the array structure this also loses the order of elements.
They will written out straight like this
key1 = This will be some funky multi line entry key2 = affe
but on reading you will only get key1 = This will be and key2 = affe.
key1 = This will be
key2 = affe
At least it does not choke on the additional multilines, as long as they don't contain a = character.
=
I only carved it out into a separate module to provide it as a light-weight dependency.
Stephen Adkins <spadkins@gmail.com>
Steffen Schwigon <ss5@renormalist.net>
This software is copyright (c) 2015 by Stephen Adkins, Steffen Schwigon.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Config::INI::Serializer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Config::INI::Serializer
CPAN shell
perl -MCPAN -e shell install Config::INI::Serializer
For more information on module installation, please visit the detailed CPAN module installation guide.