Author image Steffen Schwigon
and 2 contributors


Config::INI::Serializer - Round-trip INI serializer for nested data


Data to INI
 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);
INI to Data
 $data = $ini->deserialize($ini_text);
No functions are exported.


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.




Sample Usage:
    $serializer = Config::INI::Serializer->new;


Signature: $inidata = $serializer->serialize($data);
Param: $data (ref)
Return: $inidata (text)
Sample Usage:
    $serializer = Config::INI::Serializer->new;
    $inidata = $serializer->serialize($data);


Signature: $data = $serializer->deserialize($inidata);
Param: $inidata (text)
Return: $data (ref)
Sample Usage:
    $serializer = Config::INI::Serializer->new;
    $data = $serializer->deserialize($inidata);
    print $serializer->dump($data), "\n";


It is an extended, probably non-standard variant of INI.

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.

It turns ARRAYs into HASHes.

Array indexes are expressed like numbered hash keys:


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.

It does not handle multiline values correctly.

They will written out straight like this

 key1 = This will be
 some funky multi line
 key2 = affe

but on reading you will only get key1 = This will be and key2 = affe.

At least it does not choke on the additional multilines, as long as they don't contain a = character.


Stephen Adkins is the author of the original code.

I only carved it out into a separate module to provide it as a light-weight dependency.


  • Stephen Adkins <>

  • Steffen Schwigon <>


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.