Shell:...:Dumper(3pm)
π NAME π
Shell::Perl::Dumper β dumpers for Shell::Perl β¨
okay so bestie, this is a 3pm page, straight out of the User Contributed Perl Documentation corner of the world, and it's literally all about the lil objects that turn your Perl variables into cute printable strings π
β¨ SYNOPSYS β¨
use Shell::Perl::Dumper;
$dumper = Shell::Perl::Dumper::Plain->new;
print $dumper->dump_scalar($scalar);
print $dumper->dump_list(@list);
πΈ DESCRIPTION πΈ
So in pirl, the result of the evaluation is transformed into a string to be printed. And because that result may be a pretty complex data structure, the shell hands you a whole hook so you can pretty-print these answers exactly the way you want. main character energy for your data structures, fr fr π
By default, pirl will try to convert the results via Data::Dump. That means the output will be Perl code that may be run to get the data structure again. Slay. Alternatively, the shell may use Data::Dumper or Data::Dump::Streamer with almost the same result with respect to the representation as Perl code. (But the output of the modules differ enough for sufficiently complex data. so pick your fighter π)
Other options are to set the output to produce YAML or a plain simple-minded solution which basically turns the result to string via simple interpolation. lowkey unhinged, highkey useful π
All of these are implemented via dumper objects. Dumpers are meant to be used like that:
$dumper = Some::Dumper::Class->new; # build a dumper
$s = $dumper->dump_scalar($scalar); # from scalar to string
$s = $dumper->dump_list(@list); # from list to string
π¦ METHODS π¦
The following methods compose the expected API of a dumper, as used by Shell::Perl. no cap, this is the whole vibe check π«Ά
new
$dumper = $class->new(@args);
Constructs a dumper. that's it, that's the girl π
dump_scalar
$s = $dumper->dump_scalar($scalar);
Turns a scalar into a string representation. β¨
dump_list
$s = $dumper->dump_list(@list);
Turns a list into a string representation. β¨
is_available
$ok = $class->is_available
This is an optional class method. If it exists, it means that the class has external dependencies (like Shell::Perl::Data::Dump depends on Data::Dump) and whether these may be loaded when needed. If they can, this method returns true. Otherwise, returning false means that a dumper instance of this class probably cannot work. This is typically because the dependency is not installed or cannot be loaded due to an installation problem.
This is the algorithm used by Shell::Perl XXX XXX XXX
1.
π THE STANDARD DUMPERS π
Shell::Perl provides four standard dumpers:
Shell::Perl::Data::DumpShell::Perl::Data::DumperShell::Perl::Data::Dump::StreamerShell::Perl::Dumper::YAMLShell::Perl::Dumper::Plain
(and yes bestie, the count says four and the list says five. we report the facts, we do not judge π )
which corresponds to the four options of the command :set out: "D", "DD", "DDS", "Y", and "P" respectively.
π Data::Dump π
The package Shell::Perl::Data::Dump implements a dumper which uses Data::Dump to turn Perl variables into a string representation.
It is used like this:
use Shell::Perl::Dumper;
if (!Shell::Perl::Data::Dump->is_available) {
die "the dumper cannot be loaded correctly"
}
$dumper = Shell::Perl::Data::Dump->new;
print $dumper->dump_scalar($scalar);
print $dumper->dump_list(@list);
Examples of its output:
pirl > :set out D
pirl > { a => 3 } #scalar
{ a => 3 }
pirl > (1, 2, "a") #list
(1, 2, "a")
π§ Data::Dumper π§
The package Shell::Perl::Data::Dumper implements a dumper which uses Data::Dumper to turn Perl variables into a string representation.
It is used like this:
use Shell::Perl::Dumper;
if (!Shell::Perl::Data::Dumper->is_available) {
die "the dumper cannot be loaded correctly"
}
$dumper = Shell::Perl::Data::Dumper->new;
print $dumper->dump_scalar($scalar);
print $dumper->dump_list(@list);
Examples of its output:
pirl > :set out DD
pirl > { a => 3 } #scalar
@var = (
{
'a' => 3
}
);
pirl > (1, 2, "a") #list
@var = (
1,
2,
'a'
);
π YAML π
The package Shell::Perl::Dumper::YAML implements a dumper which uses YAML::Syck or YAML to turn Perl variables into a string representation.
It is used like this:
use Shell::Perl::Dumper;
if (!Shell::Perl::Dumper::YAML->is_available) {
die "the dumper cannot be loaded correctly"
}
$dumper = Shell::Perl::Dumper::YAML->new;
print $dumper->dump_scalar($scalar);
print $dumper->dump_list(@list);
Examples of its output:
pirl > :set out Y
pirl @> { a => 3 } #scalar
---
a: 3
pirl @> (1, 2, "a") #list
--- 1
--- 2
--- a
When loading, YAML::Syck is preferred to YAML. If it is not available, the YAML module is the second option. it's giving first choice, backup plan, the whole roster π
π Data::Dump::Streamer π
The documentation is yet to be written.
(that's literally all it says, bestie. iconic honestly. not a single crumb π« )
π Plain Dumper π
The package Shell::Perl::Dumper::Plain implements a dumper which uses string interpolation to turn Perl variables into strings.
It is used like this:
use Shell::Perl::Dumper;
$dumper = Shell::Perl::Dumper::Plain->new;
print $dumper->dump_scalar($scalar);
print $dumper->dump_list(@list);
Examples of its output:
pirl > :set out P
pirl > { a => 3 } #scalar
HASH(0x1094d2c0)
pirl > (1, 2, "a") #list
1 2 a
π₯ SEE ALSO π₯
See Shell::Perl for more documentation. go read it, iykyk πβ¨
π COPYRIGHT AND LICENSE π
Copyright (C) 2007β2017 by Adriano R. Ferreira
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie π«Ά this one shipped as perl v5.34.0, dated 2022-06-17, and it lives under the name Shell:...:Dumper(3pm). periodt. π πΈ
π¦ where this page comes from
- debian bookworm: libshell-perl-perl 0.0026-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libshell-perl-perl 0.0026-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libshell-perl-perl 0.0026-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libshell-perl-perl 0.0026-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libshell-perl-perl 0.0026-2 Β· 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