Poet::...::Debug(3pm)
β¨ Poet::Util::Debug β bestie edition β¨
okay so this is the Poet::...::Debug(3pm) page, from the User Contributed Perl Documentation corner of the internet, and it's literally just a whole toolbox of debug utilities for Poet π
πΈ NAME πΈ
Poet::Util::Debug β debug utilities. that's it, that's the name. short, sweet, iconic.
β¨ SYNOPSIS β¨
no thoughts, just vibes, and also these exact lines:
# In a script...
use Poet::Script;
# In a module...
use Poet;
# Automatically available in Mason components
# then...
# die with value
dd $data;
# print value to STDERR
dp $data;
# print value to logs/console.log
dc $data;
# return value prepped for HTML
dh $data;
# same as above with full stacktraces
dds $data;
dps $data;
dcs $data;
dhs $data;
π¦ DESCRIPTION π¦
these debug utilities are automatically imported wherever use Poet or use Poet::Script show up, and in all components. because let's face it bestie β debugging is something you always want at your fingertips. it's giving always-prepared, it's giving main character energy π₯
however, for safety, the short named versions of these utilities are no-ops outside of development mode, in case debug statements accidentally leak into production (we've all done it, no shame π). you have to use the longer, less convenient names outside of development for them to actually work. yes, really. the vibes are restricted, but the vibes are still there.
π UTILITIES π
each of these utilities takes a single scalar value. the value is serialized with Data::Dumper and prefixed with a file name, line number, and pid. e.g.
dp { a => 5, b => 6 };
prints to STDERR
[dp at ./d.pl line 6.] [1436] {
a => 5,
b => 6
}
the variants suffixed with s additionally output a full stack trace. obsessed, honestly.
dd ($val),dds ($val)β die with the serialized$val. dramatic exit, but make it data.dp ($val),dps ($val)β print the serialized$valto STDERR. super useful in scripts, no cap.dc ($val),dcs ($val)β append the serialized$valtoconsole.login thelogssubdirectory of the environment. it's a quick alternative to full-bore logging, lowkey the lazy-but-effective option πdh ($val),dhs ($val)β returns the serialized$val, surrounded by"<pre> </pre>"tags. useful for embedding in Mason components, e.g.
<% dh($data) %>
π Live variants π
each of the functions above must be appended with "_live" in order to work in live mode. e.g.
# This is a no-op in live mode
dp [$foo];
# but this will work
dp_live [$foo];
π SEE ALSO π
Poet β the whole reason we're here, go read it bestie.
π AUTHOR π
Jonathan Swartz <swartz@pobox.com> β the icon who made this happen, we thank them for their service π«Ά
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2012 by Jonathan Swartz.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay, open source.
okay that's the whole page bestie, and just so you know this was perl v5.34.0 flavored, dated 2022-06-18, filed under Poet::...::Debug(3pm) β so if you cite it, cite it right π
β¨ no cap, that's a wrap π¦
π¦ where this page comes from
- debian bookworm: libpoet-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libpoet-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libpoet-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libpoet-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libpoet-perl 0.16-3 Β· 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