Converts Perl data structures into strings that can be printed or used
eval to reconstruct the original structures. Takes a
list of scalars or reference variables and
writes out their contents in Perl syntax. Several interfaces to Data::Dumper
Simple procedural interface:
print Dumper($foo, $bar);
Extended usage with names:
print Data::Dumper->Dump([$foo, $bar], [qw(foo *ary)]);
$d = Data::Dumper->new([$foo, $bar], [qw(foo *ary)]); ... print $d->Dump;
By default, references are identified as
n is a
numeric suffix. References to substructures within
labeled using arrow notation. In the extended usage form, references
can be given user-specified names. See the Data::Dumper manpage for
examples of the module's use.
Several configuration variables can be used to control the output generated using the procedural interface. These variables control the default state of the object created by the new method. Each variable has a corresponding method that can be used later to query or modify the object. In the following list, each variable is followed by the corresponding method:
Can be set to a string that specifies an alternative to the
bless builtin operator used to create objects. A function
with the specified name should exist and should accept the
same arguments as the builtin. Default is
If set to Boolean value, enables deep copies of structures; cross-referencing is then only done when absolutely essential. Default is 0.
Controls the style of indentation for the output. Can be set to:
|0||No newlines, indentation, or spaces between list items|
Newlines, but each level in the structure is indented a fixed amount
Default. Takes into account the length of hash keys so the hash values line up.
If set to a method name, Data::Dumper invokes that method via the object before attempting to turn it into a string. Set to an empty string to disable. Default is empty string.
Specifies the string that is prefixed to every output line. Default is an empty string.
Controls degree to which
eval can recreate the original reference
structures. Setting the value to
1 outputs additional Perl statements to
correctly recreate nested references. Default is
If set to a Boolean value, controls whether hash keys
are quoted. If false, avoids quoting hash keys
that look like a simple string. Default is
always quotes hash keys.
When set, Data::Dumper outputs single, non-self-referential values as
atoms or terms rather than as statements.
n names are avoided
as much as possible. Such output may not be parsable by
If set to a method name, Data::Dumper issues a method call
for any objects that are to be dumped using the syntax
bless(data, class)->method(). Set to an empty string to
disable. Default is empty string.
When set, enables the use of double quotes to represent string values. In
\r are used to represent non-space
whitespace; "unsafe" characters are backslashed; and unprintable characters
are output as quoted octal integers. Default is
0. Currently, the
method does not honor this flag.
Specifies the prefix to use for tagging variable names in the output.
The following methods and functions are provided: