Data::Dumper#

Native implementation of Data::Dumper

Provides data structure serialization to Perl syntax.

Perl Equivalent#

Data::Dumper

Synopsis#

use Data::Dumper;

print Dumper(\%hash, \@array);

my $d = Data::Dumper->new([$ref], ['name']);
$d->Indent(1);
$d->Sortkeys(1);
print $d->Dump();

Functions#

Dumper#

Dumps one or more references to Perl syntax. Returns a string containing the serialized representation.

use Data::Dumper;
print Dumper($hashref, $arrayref);
# $VAR1 = { 'key' => 'value' };
# $VAR2 = [ 1, 2, 3 ];

new#

Creates a Data::Dumper object for fine-grained control over serialization options.

my $d = Data::Dumper->new([$ref1, $ref2], [qw(name1 name2)]);
print $d->Dump();

Dump#

Returns the serialized string from a Data::Dumper object. Alias: Dumpxs().

Reset#

Resets the internal seen-address cache so the next Dump() call starts fresh (no back-references to previous dumps).

Indent#

Gets or sets the indentation level (0=none, 1=fixed, 2=adaptive).

Sortkeys#

Gets or sets whether hash keys are sorted alphabetically in output.

Output Format#

The output follows Perl’s Data::Dumper format:

  • Scalar references: $VAR1 = \'value';

  • Array references: $VAR1 = [ ... ];

  • Hash references: $VAR1 = { 'key' => value, ... };

  • Circular references: \$VAR1->{'key'} (back-reference to already-seen value)