Data::...er::OO(3pm)
π Data::TreeDumper::OO β the object-oriented glow-up of Data::TreeDumper π
okay bestie, so this is a page from the User Contributed Perl Documentation, and it's literally the manual for Data::TreeDumper::OO, which is the object-oriented era of the whole TreeDumper situation. she's giving main character energy, she's on CPAN, she's ready to dump your data structures in the prettiest way possible. let's get into it π
β¨ NAME β¨
Data::TreeDumper::OO β Object oriented interface to Data::TreeDumper
like, an actual interface. with objects. we love to see it π
πΈ SYNOPSIS πΈ
here's the whole vibe, verbatim, no notes:
use Data::TreeDumper ;
use Data::TreeDumper::OO ;
my $sub = sub {} ;
my $s =
{
A =>
{
a =>
{
}
, bbbbbb => $sub
, c123 => $sub
, d => \$sub
}
, C =>
{
b =>
{
a =>
{
a =>
{
}
, b => sub
{
}
, c => 42
}
}
}
, ARRAY => [qw(elment_1 element_2 element_3)]
} ;
my $dumper = new Data::TreeDumper::OO() ;
$dumper->UseAnsi(1) ;
$dumper->SetMaxDepth(2) ;
$dumper->SetFilter(\&Data::TreeDumper::HashKeysSorter) ;
print $dumper->Dump($s, "Using OO interface") ;
print $dumper->DumpMany
(
[$s, "title", MAX_DEPTH => 1]
, [$s2, "other_title", DISPLAY_ADDRESS => 0]
, USE_ASCII => 1
, MAX_DEPTH => 5
) ;
π¦ Output π¦
and here's what that actually prints, because the output is honestly kind of iconic:
title:
|- A [H1]
| |- a [H2]
| |- bbbbbb = CODE(0x8139fa0) [C3]
| |- c123 [C4 -> C3]
| `- d [R5]
| `- REF(0x8139fb8) [R5 -> C3]
|- ARRAY [A6]
| |- 0 [S7] = elment_1
| |- 1 [S8] = element_2
| `- 2 [S9] = element_3
`- C [H10]
`- b [H11]
`- a [H12]
|- a [H13]
|- b = CODE(0x81ab130) [C14]
`- c [S15] = 42
look at those little box-drawing branches. tree. so satisfying. π
π DESCRIPTION π
Object oriented interface to Data::TreeDumper.
that's the whole pitch, fr fr. it's Data::TreeDumper but you hold a $dumper object and call methods on it instead of passing a million arguments around like a feral gremlin. slay.
π Object oriented Methods π
okay this is the good part, the whole menu of things you can call. copy-paste this energy:
# constructor
my $dumper = new Data::TreeDumper::OO(MAX_DEPTH => 1) ;
$dumper->UseAnsi(1) ;
$dumper->UseAscii(1) ;
$dumper->SetMaxDepth(2) ;
$dumper->SetIndentation(' ') ;
$dumper->SetVirtualWidth(80) ;
$dumper->SetFilter(\&Data::TreeDumper::HashKeysSorter) ;
$dumper->SetLevelFilters({1 => \&Filter_1, 5 => \&Filter_5) ;
$dumper->SetStartLevel(0) ;
$dumper->QuoteHashKeys(1) ;
$dumper->QuoteValues(0) ;
$dumper->DisplayNoElements(1) ;
$dumper->DisplayRootAddress(1) ;
$dumper->DisplayAddress(0) ;
$dumper->DisplayObjectType(0) ;
$dumper->Displayinheritance(0) ;
$dumper->DisplayAutoload(0) ;
$dumper->DisplayTie(0) ;
$dumper->DisplayPerlAddress(1) ;
$dumper->DisplayPerlSize(0) ;
$dumper->NumberLevels(2) ;
$dumper->ColorLevels(\&ColorLevelSub) ;
$dumper->SetGlyphs(['. ', '. ', '. ', '. ']) ;
$dumper->NoOutput(1) ;
$dumper->SetRenderer('DHTML') ;
$dumper->Dump($s, "Using OO interface", %OVERRIDES) ;
$dumper->DumpMany
(
[$s, "dump1", %OVERRIDES]
, [$s, "dump2", %OVERRIDES]
, %OVERRIDES
) ;
so yeah β you make a $dumper, you set all your settings with method calls (ansi or ascii, max depth, indentation, virtual width, filters, level filters, start level, quoting, all the Display* toggles, perl address, perl size, numbering, colors, glyphs, no-output, renderer...), and then you Dump one thing or DumpMany a whole list of things with per-item %OVERRIDES and global %OVERRIDES on top. chef's kiss. π«Ά
π DEPENDENCY π
Data::TreeDumper.
that's it. she needs her base class to exist. that's the whole relationship. π
π§ EXPORT π§
None.
nothing. zero. we don't do that here. it's OO, babes. you call methods. π
β SEE ALSO β
Data::TreeDumperβ the base class for this module. that's the mothership, the blueprint, the OG.Data::Dumperβ convert perl data values or variables to equivalent Perl syntax.Data::Dumper::GUIβ a graphical interface on top ofData::Dumper.Data::Dumper::Sortedβ likeData::Dumperbut sorts hash keys into alphabetic order.Data::Dumper::HTMLβ dump data into HTML with syntax highlighting.Data::Dumper::SimpleandData::Dumper::Nameswork likeData::Dumperbut include the original variable names in the output.Data::Dumper::Perltidyβ combinesData::DumperandPerl::Tidyto stringify data in a pretty-printed format.Text::Tree::Indentedβ format tree data in an indented tree format, using ASCII or box-rule characters.
a whole family reunion. the Data::Dumper cinematic universe. π
π REPOSITORY π
the code lives over at:
<https://github.com/neilbowers/Data-TreeDumper-OO>
go say hi, maybe star it, iykyk β
π AUTHOR π
Khemir Nadim ibn Hamouda. <nadim@khemir.net>
π COPYRIGHT AND LICENSE π
Copyright (c) 2003-2014 Nadim Ibn Hamouda el Khemir. All rights reserved.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
If you find any value in this module, mail me! All hints, tips, flames and wishes are welcome at <nadim@khemir.net>.
not the author personally asking for flames in the year of our lord π respect though, honestly, that's transparency.
okay so that's the whole page bestie, you're basically a Data::TreeDumper::OO expert now, no cap π
β¨
perl v5.32.1 Β· 2021-09-26 β that's the version and date this page was last touched, so if you're reading this on a newer perl, consider that your official timestamped sign-off. bye babes, go dump some trees π¦ππΈ
π¦ where this page comes from
- debian bookworm: libdata-treedumper-oo-perl 0.10-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdata-treedumper-oo-perl 0.10-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libdata-treedumper-oo-perl 0.10-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdata-treedumper-oo-perl 0.10-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdata-treedumper-oo-perl 0.10-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdata-treedumper-oo-perl 0.10-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms