A pure-oo reimplementation of dumpvar.pl
use Devel::Dumpvar; # Dump something immediately to STDOUT Devel::Dumpvar->dump( [ 'foo' ], $bar' ); # Create a dump handle to use repeatedly my $Dump = Devel::Dumpvar->new; # Dump via the handler $Dump->dump( 'foo', [ 'bar' ] );
Most perl dumping modules are focused on serializing data structures into a format that can be rebuilt into the original data structure. They do this with a variety of different focuses, such as human readability, the ability to execute the dumped code directly, or to minimize the size of the dumped data.
Excect for the one contained in the debugger, in the file dumpvar.pl. This is a much more human-readable form, highly useful for debugging, containing a lot of extra information without the burden of needing to allow the dump to be re-assembled into the original data.
The main downside of the dumper in the perl-debugger is that the dumpvar.pl script is not really a readily loadable and useable module. It has dedicated hooks from and to the debugger, and spans across multiple namespaces, including main::.
Devel::Dumpvar is a pure object-orientated reimplementation of the same functionality. This makes it much more versatile version to use for dumping information to debug log files or other uses where you don't need to reassemble the data.
The \*(C`new\*(C' constructor creates a new dumping object. Any options can be passed a list of key/value pairs.
Each option passed to the constructor is set via one of the option methods below. The \*(C`to\*(C' option specifies where the output is to be sent to. When undefined, output will go to \s-1STDOUT\s0. The output destination can be either a handle object ( or anything else with a ->print method ), or the string 'return', which will cause the \*(C`dump\*(C' method to collect and return the dump results for each call, rather than printing it immediately to the output.
If called without an argument, returns the current value. If called with an argument, returns true or dies on error.
If called as an object method, dumps a number of data values or structs to the dumping object. If called as a class method, creates a new default dump object and immediately dumps to it, destroying the dumper afterwards.
- Implement options currently available in other dumpers as needed.
- Currently only supports SCALAR, REF, ARRAY, HASH and Regexp. Add support for all possible reference types.
Bugs should be reported via the \s-1CPAN\s0 bug tracker at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Devel-Dumpvar <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Devel-Dumpvar>
For other issues, or commercial enhancement or support, contact the author.
Adam Kennedy <[email protected]>
Copyright 2004 - 2010 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the \s-1LICENSE\s0 file included with this module.