Poet::...::Debug(3pm)

πŸ“¦
version 0.16 Β· 2 versions
  • 0.16 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.16 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ 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 $val to STDERR. super useful in scripts, no cap.
  • dc ($val), dcs ($val) β€” append the serialized $val to console.log in the logs subdirectory 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 🫢


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