Devel::MAT::Cmd(3pm)
β¨ NAME β¨
Devel::MAT::Cmd β abstractions for providing commands for Devel::MAT π
okay so basically this is the lil' toolkit module that other Devel::MAT commands lean on when they wanna print stuff pretty. It's lowkey the aesthetic department of the whole dumpfile-inspecting operation: tables, formatted values, symbols, byte counts, headings β the whole glow-up package. π
π¦ METHODS π¦
π printf
Devel::MAT::Cmd->printf( $fmt, @args )
Does exactly what perl's core printf() does, no cap. BUT β and this is the iconic part β any argument that lands in a %s conversion can also be the result of one of the format_* methods below, and those babies may hand you back a String::Tagged instance instead of a boring plain string. So you get formatting and styling in one go. obsessed. β¨
π print_table
Devel::MAT::Cmd->print_table( $rows, %opts )
You give it a 2D array-of-arrays full of strings β plain ones, or the fancy formatted ones the various format_* methods return β and it prints them all lined up in a table shape, columns all aligned and neat. periodt.
Pro tip: an element of $rows can be an empty arrayref, and that makes a row of divisions get drawn using hyphens (-) the full width of each column. cute little separator, slay.
The following named %ops may be supplied:
headings => ARRAY[STRING]β a list of strings, one per column, to place at the top of the table. You can format these differently if you want them to stand out, bestie. πsep => ARRAY[STRING]orSTRINGβ a list of strings per column (or just one single string to apply equally to them all) saying what separator string to print after each column. Defaults to a single space if you don't supply it. Warning tho: this string gets interpolated into asprintfformat string, so any%marks it contains should be doubled. πalign => ARRAY[STRING]orSTRINGβ a list of strings per column (or one single string to apply to all of them) saying how data in the column should be aligned. It aligns to the right if the value isright.indent => INTβ how many spaces to prefix before every row of output. Defaults to zero if you don't supply it.
π format_note
$str = Devel::MAT::Cmd->format_note( $str, $idx )
Slaps some kind of styling onto the string you hand it. Starting from zero, successively higher integer values for $idx may influence the style even further. Anything output with the same index value will come out looking the same. The implementation should support at least 3 different styles, but it may wrap around after that.
For stylistic consistency, tools should try to stick to these conventions for note indexes:
0 - regular notes
1 - secondary notes, lexical variable names
2 - unusual or erroneous conditions, symbol table names
π format_sv
$str = Devel::MAT::Cmd->format_sv( $sv )
Returns a string encoding the address and description of the given SV. It might be stylised in some way, it's subject to user customisation, and it might even be made interactive if the UI is capable of that. main character energy fr fr. π
π format_value
$str = Devel::MAT::Cmd->format_value( $val, %opts )
Returns a string formatting a given plain scalar value β which should either be a string or a number β so it reads as a value from the user program. If you hand it a string value, it gets escaped and quoted appropriately. responsible queen. β¨
The following named %opts may be supplied:
key => BOOLβ if true, the value represents a hash key value. Wraps the result in braces{...}and removes redundant quote marks if the string is valid as a bareword identifier.index => BOOLβ if true, the value represents an array index. Wraps the result in square brackets[...]and expects the value to be an integer.addr => BOOLβ if true, the value represents some (non-SV) address. Prepends a0xand formats the value as a hexadecimal string.pv => BOOLβ if true, the value represents a string from the user code. Wraps the result in quote marks"..."and limits the length to a maximum of 64 characters (or as specified by themaxlenargument). No truncation ifmaxlenis zero.
π format_symbol
$str = Devel::MAT::Cmd->format_symbol( $name, $sv )
Returns a string formatting the given symbol name so it's clear it's a symbol name. Optionally you can pass the SV object itself too, which may save the UI from having to look it up from the dumpfile in case it wants to make the printed value interactive somehow. optional but iconic. π«Ά
π format_bytes
$str = Devel::MAT::Cmd->format_bytes( $bytes )
Returns a string showing the given byte count in suitably scaled units. It'll use base-1024 sizes in KiB, MiB, GiB or TiB if necessary. math but make it cute. β¨
π§ format_sv_with_value
$str = Devel::MAT::Cmd->format_sv_with_value( $sv )
Similar to format_sv, but it prints additional info on some kinds of SVs so the user doesn't have to reach for show just to figure out what they're looking at.
Specifically:
- For
SCALARSVs it shows the value directly by usingformat_value. - For
REFSVs it shows the referrant SV. - For
STASHSVs it shows the symbol name.
β format_heading
$str = Devel::MAT::Cmd->format_heading( $text, $level )
Returns a string applying some formatting to the given text to make it stand out as a section or table heading. $level may be used to distinguish different styles; at least 3 should be provided.
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk>
and that's a wrap bestie π this was perl v5.42.3, dated 2026-08-21, and yes, the page is literally called Devel::MAT::Cmd(3pm) β go forth and format things, you're gonna slay π¦π
π¦ where this page comes from
- ubuntu stonking: libdevel-mat-perl 0.54-1build1 Β· 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