Catman...:format(3pm)

πŸ“¦
version 1.2025 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

✨ Catmandu::Fix::format β€” the manual page, but make it cute ✨

okay bestie so we're looking at Catmandu::Fix::format, from the User Contributed Perl Documentation, and it's literally the glow-up your values have been waiting for πŸ’…


πŸ’– NAME πŸ’–

Catmandu::Fix::format β€” swaps your value out for a formatted, sprintf-ish version of it. it's giving makeover montage πŸŽ€


🌸 SYNOPSIS 🌸

okay so here's the whole vibe, example by example:

# e.g. number: 41
format(number,"%-10.10d") # number => "0000000041"

# e.g. numbers:
#         - 41
#         - 15
format(number,"%-10.10d %-5.5d") # numbers => "0000000041 00015"

# e.g. hash:
#        name: Albert
format(name,"%-10s: %s") # hash: "name      : Albert"

# e.g. array:
#         - 1
format(array,"%d %d %d") # Fails! The array contains only one value, but you request 3 values

# Test first if the array contains 3 values
if exists(array.2)
  format(array,"%d %d %d")
end

not the array example calling you out in public 😭 yes, format(array,"%d %d %d") Fails! because the array contains only one value but you're out here requesting 3 values. the audacity. so the fix is right there: test first if the array contains 3 values, then format. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

bestie, this fix creates a string formatted by the usual printf conventions of the C library function sprintf. that's the whole thing. the way that it just... hands the formatting over to sprintf and lets it cook πŸ‘‘

want the full rundown? see <http://perldoc.perl.org/functions/sprintf.html> for a complete description. iykyk ✨


πŸ‘‘ SEE ALSO πŸ‘‘

  • Catmandu::Fix
  • sprintf

and that's the page, no cap πŸ’œ

this was pulled from the docs as of 2026-01-24, shipped with perl v5.40.1, and yes it's Catman...:format(3pm) at the bottom too, mwah πŸ’‹ go format something iconic, bestie 🌈⭐

πŸ“¦ where this page comes from