Data::Dump - Pretty printing of data structures |
Data::Dump - Pretty printing of data structures
use Data::Dump qw(dump);
$str = dump(@list) @copy_of_list = eval $str;
This module provide a single function called dump()
that takes a list
of values as argument and produce a string as result. The string
contains perl code that when eval
ed will produce a deep copy of the
original arguments. The string is formatted for easy reading.
If dump()
is called in void context, then the dump will be printed on
STDERR instead of being returned.
If you don't like to import a function that overrides Perl's not-so-useful builtin, then you can also import the same function as pp(), mnemonic for ``pretty-print''.
The Data::Dump
module grew out of frustration with Sarathy's
in-most-cases-excellent Data::Dumper
. Basic ideas and some code is shared
with Sarathy's module.
The Data::Dump
module provide a much simpler interface than
Data::Dumper
. No OO interface is available and there are no
configuration options to worry about (yet :-). The other benefit is
that the dump produced does not try to set any variables. It only
returns what is needed to produce a copy of the arguments. It means
that dump("foo")
simply returns "foo"
, and dump(1..5)
simply
returns (1, 2, 3, 4, 5)
.
the Data::Dumper manpage, the Storable manpage
The Data::Dump
module is written by Gisle Aas <gisle@aas.no>, based
on Data::Dumper
by Gurusamy Sarathy <gsar@umich.edu>.
Copyright 1998-2000 Gisle Aas. Copyright 1996-1998 Gurusamy Sarathy.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Data::Dump - Pretty printing of data structures |