1PPI::Dumper(3) User Contributed Perl Documentation PPI::Dumper(3)
2
3
4
6 PPI::Dumper - Dumping of PDOM trees
7
9 # Load a document
10 my $Module = PPI::Document->new( 'MyModule.pm' );
11
12 # Create the dumper
13 my $Dumper = PPI::Dumper->new( $Module );
14
15 # Dump the document
16 $Dumper->print;
17
19 The PDOM trees in PPI are quite complex, and getting a dump of their
20 structure for development and debugging purposes is important.
21
22 This module provides that functionality.
23
24 The process is relatively simple. Create a dumper object with a
25 particular set of options, and then call one of the dump methods to
26 generate the dump content itself.
27
29 new $Element, param => value, ...
30 The "new" constructor creates a dumper, and takes as argument a single
31 PPI::Element object of any type to serve as the root of the tree to be
32 dumped, and a number of key->value parameters to control the output
33 format of the Dumper. Details of the parameters are listed below.
34
35 Returns a new "PPI::Dumper" object, or "undef" if the constructor is
36 not passed a correct PPI::Element root object.
37
38 memaddr
39 Should the dumper print the memory addresses of each PDOM element.
40 True/false value, off by default.
41
42 indent
43 Should the structures being dumped be indented. This value is
44 numeric, with the number representing the number of spaces to use
45 when indenting the dumper output. Set to '2' by default.
46
47 class
48 Should the dumper print the full class for each element.
49 True/false value, on by default.
50
51 content
52 Should the dumper show the content of each element. True/false
53 value, on by default.
54
55 whitespace
56 Should the dumper show whitespace tokens. By not showing the
57 copious numbers of whitespace tokens the structure of the code can
58 often be made much clearer. True/false value, on by default.
59
60 comments
61 Should the dumper show comment tokens. In situations where you have
62 a lot of comments, the code can often be made clearer by ignoring
63 comment tokens. True/false value, on by default.
64
65 locations
66 Should the dumper show the location of each token. The values shown
67 are [ line, rowchar, column ]. See "location" in PPI::Element for a
68 description of what these values really are. True/false value, off
69 by default.
70
71 print
72 The "print" method generates the dump and prints it to STDOUT.
73
74 Returns as for the internal print function.
75
76 string
77 The "string" method generates the dump and provides it as a single
78 string.
79
80 Returns a string or undef if there is an error while generating the
81 dump.
82
83 list
84 The "list" method generates the dump and provides it as a raw list,
85 without trailing newlines.
86
87 Returns a list or the null list if there is an error while generating
88 the dump.
89
91 See the support section in the main module.
92
94 Adam Kennedy <adamk@cpan.org>
95
97 Copyright 2001 - 2011 Adam Kennedy.
98
99 This program is free software; you can redistribute it and/or modify it
100 under the same terms as Perl itself.
101
102 The full text of the license can be found in the LICENSE file included
103 with this module.
104
105
106
107perl v5.36.0 2023-01-20 PPI::Dumper(3)