PPI::Dumper(3)

✨ NAME ✨

PPI::Dumper β€” dumping of PDOM trees, bestie πŸ’–


🌸 SYNOPSIS 🌸

# Load a document
my $Module = PPI::Document->new( 'MyModule.pm' );

# Create the dumper
my $Dumper = PPI::Dumper->new( $Module );

# Dump the document
$Dumper->print;

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so the PDOM trees in PPI? they are a lot. like, genuinely complex, no cap. and when you're doing development and debugging, being able to actually get a dump of their structure is important β€” it's giving essential, fr fr.

this module provides exactly that functionality. you're welcome πŸ’…

the process is lowkey 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. that's it. that's the whole vibe. ✨


πŸŽ€ METHODS πŸŽ€

new $Element, param => value, ...

the new constructor creates a dumper, and takes as argument a single PPI::Element object of any type to serve as the root of the tree to be dumped, plus a number of key->value parameters to control the output format of the Dumper. details of the parameters are listed below πŸ‘‡

returns a new PPI::Dumper object, or undef if the constructor is not passed a correct PPI::Element root object. so like, don't do that 🫢

  • memaddr β€” should the dumper print the memory addresses of each PDOM element? true/false value, off by default.
  • indent β€” 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. cute lil two-space indent ✨
  • class β€” should the dumper print the full class for each element? true/false value, on by default.
  • content β€” should the dumper show the content of each element? true/false value, on by default.
  • whitespace β€” 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.
  • comments β€” 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/false value, on by default.
  • locations β€” should the dumper show the location of each token? the values shown are [ line, rowchar, column ]. see "location" in PPI::Element for a description of what these values really are. true/false value, off by default.

print

the print method generates the dump and prints it to STDOUT.

returns as for the internal print function. πŸ’…


string

the string 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. 😭


list

the list 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 generating the dump.


πŸ’œ SUPPORT πŸ’œ

see the support section in the main module. iykyk 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Adam Kennedy <adamk@cpan.org>


Copyright 2001 - 2011 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 LICENSE file included with this module.


ok that's the whole page bestie, go dump some trees πŸ’–πŸŒ³

mwah πŸ’‹ β€” this was PPI::Dumper(3), from perl v5.42.0, dated 2026-01-17. periodt. ✨

πŸ“¦ where this page comes from