Name
Data::Undump::PPI - Perl extension for limited undumping of data structures via PPI
Synopsis
use Data::Dumper;
use Data::Undump::PPI; # exports the "Undump()" function
my @input = ( {foo=>"bar"}, ["Hello","World"], "undumping!" );
my $str = Dumper(@input); # dump the data structure to a string
my @parsed = Undump($str); # parse the data structure back out
# @parsed now looks like this:
# ( { 'foo' => 'bar' },
# [ 'Hello', 'World' ],
# 'undumping!' )
Description
This module allows for limited undumping and round-tripping of data structures from strings generated by modules such as Data::Dumper and Data::Dump. It is a thin wrapper around Config::Perl, so please see Config::Perl for more details, including the limitations.
This module exports a single function, Undump
, which attempts to return the data as it would have been passed to Data::Dumper's Dumper
or Data::Dump's dump
functions. This means that for example, the $VAR1
variables generated by Dumper
will be stripped. If the string doesn't look like the output of one of the dumper modules, the output of Config::Perl's parse_or_die
will be passed through. Undump
will die
if it encounters problems.
Because at the moment Config::Perl has only very limited support for references, self-referential data structures will most likely not work (support may be added in a later release of Config::Perl). For now, a possible workaround may be Data::Dumper's Deepcopy
option, if the loss of references and copying of data is acceptable for your application.
If you're using Data::Dump, note that some of the code it generates is currently unsupported by Config::Perl, such as the range operator ..
. Because of this, you may be better off using Data::Dumper for now.
If you're using Data::Dumper, note that its Terse
option may cause Dumper
to generate invalid Perl strings if you pass it more than one value.
This module is part of the Config::Perl distribution, but was named seperately in an attempt to make its purpose more clear and its name a little easier to remember.
This document describes version 0.02 of the module. Although this module is well-tested and working, it still lacks some features to make it really useful (see Config::Perl). Contributions are welcome!
Author, Copyright, and License
Copyright (c) 2015 Hauke Daempfling (haukex@zero-g.net).
This library is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.
For more information see the Perl Artistic License, which should have been distributed with your copy of Perl. Try the command "perldoc perlartistic
" or see http://perldoc.perl.org/perlartistic.html.