Dumping of mdom trees
# Load a document my $Module = MDOM::Document->new( 'MyMakefile' ); # Create the dumper my $Dumper = MDOM::Dumper->new( $Module ); # Dump the document $Dumper->print;
The \s-1MDOM\s0 trees in \s-1MDOM\s0 are quite complex, and getting a dump of their structure for development and debugging purposes is important.
This module provides that functionality.
The process is relatively simple. Create a dumper object with a particular set of options, and then call one of the dump methods to generate the dump content itself.
The \*(C`new\*(C' constructor creates a dumper, and takes as argument a single MDOM::Element object of any type to serve as the root of the tree to be dumped, and a number of key->value parameters to control the output format of the Dumper. Details of the parameters are listed below.
Returns a new \*(C`MDOM::Dumper\*(C' object, or \*(C`undef\*(C' if the constructor is not passed a correct MDOM::Element root object.
Should the dumper print the memory addresses of each \s-1MDOM\s0 element. True/false value, off by default.
Should the structures being dumped be indented. This value is numeric, with the number representing the number of spaces to use when indenting the dumper output. Set to '2' by default.
Should the dumper print the full class for each element. True/false value, on by default.
Should the dumper show the content of each element. True/false value, on by default.
Should the dumper show whitespace tokens. By not showing the copious numbers of whitespace tokens the structure of the code can often be made much clearer. True/false value, on by default.
Should the dumper show comment tokens. In situations where you have a lot of comments, the code can often be made clearer by ignoring comment tokens. True/value value, on by default.
Should the dumper show the location of each token. The values shown are [ line, rowchar, column ]. See \*(L"location\*(R" in MDOM::Element for a description of what these values really are. True/false value, off by default.
The \*(C`print\*(C' method generates the dump and prints it to \s-1STDOUT\s0.
Returns as for the internal print function.
The \*(C`string\*(C' method generates the dump and provides it as a single string.
Returns a string or undef if there is an error while generating the dump.
The \*(C`list\*(C' method generates the dump and provides it as a raw list, without trailing newlines.
Returns a list or the null list if there is an error while generation the dump.
See the support section in the main module.
Adam Kennedy <[email protected]>
Zhang \*(L"agentzh\*(R" Yichun \*(C`<[email protected]>\*(C'
Copyright 2001 - 2006 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.