NAME

Data::XDumper - Human readable dumps of perl data structures with labeled cross-references.

SYNOPSIS

use Data::XDumper;

my $dump = new Data::XDumper usehex => 1;
print scalar $dump->dump([1, 2, 1024]);
print "$_\n" for $dump->dump({ foo => sub{}, 'bar ' => ["\n"] });
$dump->usehex = 0;
print scalar $dump->dump([1, 2, 1024]);

my $test = ["foo"];
push @$test, \$test;
Data::XDumper::Default->indent = "  ";
Data::XDumper::Dump $test;

use Data::XDumper qw(Dump);

print scalar Dump [1, "x" x 60, 42];

DESCRIPTION

Produces dumps of almost any kind of perl datastructure, in a format which I personally find a lot more readable than that of Data::Dumper.

The dump returns the output lines in list context. Otherwise it produces a big string containing the whole dump, and in void context prints it too.

There are a few settings you can set on the dumper object. When you create a new dumper, it inherits the settings from the default object, which is returned by Data::XDumper::Default.

Methods

PACKAGE->dump(LIST)

Dump the list of items using the default object (see Functions below).

$OBJ->dump(LIST)

Dump the list of items.

$OBJ->reset

Reset the dumper object to its initial state. This clears the list of references it has seen, and resets the label counter.

Properties

$OBJ->usehex

Use hexadecimal notation for integers in range -0xFFFFFFFF .. -0xA and 0xA .. 0xFFFFFFFF.

$OBJ->indent

The string used to increase the indentation level.

$OBJ->prefix

The string prefixed to every output line. Note that this string should accomodate space for the labels. By default it is 8 spaces.

$OBJ->linelen

The maximum desired line length. If a single-line form of a value exceeds this length, XDumper will use multi-line form instead.

$OBJ->lformat

The format for labels. Must match /^[A-Za-z0-9]+\z/. You need to reset the object before change of label format takes effect.

Functions

Dump LIST

Dump the list of items using the default object.

Default

Returns the default object, to allow you to change its settings.

KNOWN ISSUES

The code is ugly and devoid of comments. The documentation is too brief. But it does seem to work though :-)

I'm still looking into what to do with CODE refs.. for now they're just formatted as CODE.

AUTHOR

Matthijs van Duin <xmath@cpan.org>

Copyright (C) 2003 Matthijs van Duin. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.