NAME
UNIVERSAL::dump - add dump methods to all classes and objects
SYNOPSIS
use UNIVERSAL::dump; # implicit dump => 'Data::Dumper::Dumper'
or:
use UNIVERSAL::dump (
_dump => 'Data::Dumper::Dumper',
);
or:
use UNIVERSAL::dump (
dump => 'Data::Dumper::Dumper',
peek => 'Devel::Peek::Dump',
);
my $foo = Foo->new;
print $foo->dump; # send dump of $foo to STDOUT
print $foo->dump( $bar ); # send dump of $bar to STDOUT
$foo->dump; # send dump of $foo to STDERR
$foo->dump( $bar ); # send dump of $bar to STDERR
DESCRIPTION
Loading the UNIVERSAL::dump module adds one or more methods to all classes and methods. It is intended as a debugging aid, alleviating the need to add and remove debugging code from modules and programs.
By default, it adds a method "dump" to all classes and objects. This method either dumps the object, or any parameters specified, using Data::Dumper.
The name of the method, and the name of the subroutine to be called, can be specified by parameters when loading the module. One example is creating a "peek" method that will us Devel::Peek to dump the contents of the object or anything else passed to the dump method.
As an extra feature, the output is sent to STDERR whenever the method is called in a void context. This makes it easier to dump variable structures while debugging modules and programs.
WHY?
One day, I finally had enough of always putting a "dump" and "peek" method in my modules. I came across UNIVERSAL::moniker one day, and realized that I could do something similar for my "dump" methods.
REQUIRED MODULES
Data::Dumper (any)
CAVEATS
AUTOLOADing methods
Any method called "dump" (or whichever class or object methods you activate with this module) will not be AUTOLOADed because they are already found in the UNIVERSAL package..
AUTHOR
Elizabeth Mattijsen, <liz@dijkmat.nl>.
Please report bugs to <perlbugs@dijkmat.nl>.
COPYRIGHT
Copyright (c) 2004 Elizabeth Mattijsen <liz@dijkmat.nl>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.