autobox::dump(3pm)
π autobox::dump π
okay bestie, so this is the autobox::dump page β it lives in the User Contributed Perl Documentation and it's basically the β¨glow-upβ¨ that lets you turn any EXPR into a human-readable AND perl-readable string. no cap.
πΈ NAME πΈ
autobox::dump β human/perl readable strings from the results of an EXPR. yes, the whole point. it's giving "print literally anything and have it look cute". π
β¨ VERSION β¨
Version 20090426.1746 β vintage, iconic, still slaying.
π¦ SYNOPSIS π¦
The autobox::dump pragma adds, via the autobox pragma, a method to normal expression (such as scalars, arrays, hashes, math, literals, etc.) that produces a human/perl readable representation of the value of that expression. π«Ά
use autobox::dump;
my $foo = "foo";
print $foo->perl; # "foo";
print +(5*6)->perl; # 30;
my @a = (1..3);
print @a->perl;
# [
# 1,
# 2,
# 3
# ];
print {a=>1, b=>2}->perl;
# {
# "a" => 1,
# "b" => 2
# };
sub func {
my ($x, $y) = @_;
return $x + $y;
}
my $func = \&func;
print $func->perl;
#sub {
# BEGIN {
# $^H{'autobox_scope'} = q(154456408);
# $^H{'autobox'} = q(HASH(0x93a3e00));
# $^H{'autobox_leave'} = q(Scope::Guard=ARRAY(0x9435078));
# }
# my($x, $y) = @_;
# return $x + $y;
#}
like, $foo->perl?? on a plain scalar?? on MATH?? bestie the power. ππ
π setting your options π
You can set Data::Dumper options by passing either arrayrefs of option and value pairs or just keys (in which case the option will be set to 1). The default options are qw/Indent Terse Useqq Sortkeys Deparse/. π
print ["a", 0, 1]->perl([Indent => 3], [Varname => "a"], qw/Useqq/);
#$a1 = [
# #0
# "a",
# #1
# 0,
# #2
# 1
# ];
(arrayrefs for pairs, plain keys for "just turn it on" β 1-ing it, as one does.)
π the class method π
You can also call the class method ->options to set a different default. this is your global vibe-setter, fr fr.
#set Indent to 0, but leave the rest of the options
autobox::dump->options([Indent => 0], qw/Terse Useqq Sortkeys Deparse/);
print ["a", 0, 1]->perl; #["a",0,1]
look at that last line. #["a",0,1]. compact. iconic. π§
π AUTHOR π
Chas. J Owens IV, <chas.owens at gmail.com>. the mastermind. πββοΈ
π BUGS π
okay so, the not-so-cute part, but we're being honest here:
- Has all the issues
autoboxhas. - Has all the issues
Data::Dumperhas. - This pragma errs on the side of human readable to the detriment of Perl readable. In particular it uses the terse and deparse options of
Data::Dumperby default. These options may create code that cannot beeval'ed. For bestevalresults, set options to"qw/Purity/". Note, this turns off coderef dumping.
β οΈ bestie read that again: it may produce code that cannot beeval'ed. it's pretty, not always runnable. if you need it to actuallyeval, go"qw/Purity/"β but then coderef dumping is off. tradeoffs, periodt.
Please report any bugs or feature requests to http://github.com/cowens/autobox-dump/issues π
π«Ά SUPPORT π«Ά
You can find documentation for this module with the perldoc command.
perldoc autobox::dump
one command. self-care. β¨
π ACKNOWLEDGEMENTS π
Michael Schwern for starting the perl5i pragma which prompted me to add a feature I wanted to autobox. ty king π
π COPYRIGHT & LICENSE π
Copyright 2009 Chas. J Owens IV, all rights reserved.
This program 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 came to you from perl v5.40.0, dated 2024-08-25, in the autobox::dump(3pm) corner of the User Contributed Perl Documentation π go forth and ->perl everything you can get your hands on ππ¦π
π¦ where this page comes from
- ubuntu resolute: libautobox-dump-perl 20090426.1746-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libautobox-dump-perl 20090426.1746-6 Β· 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