Test::...essors(3pm)
π NAME π
Test::Run::Sprintf::Named::FromAccessors β named sprintf according to the values of accessors. (Yeah bestie, that's the whole vibe. It's from the User Contributed Perl Documentation, section 3pm, so it's a Perl module page, obvs.)
β¨ SYNOPSIS β¨
Okay so here's literally how you use it:
my $formatter =
Test::Run::Sprintf::Named::FromAccessors->new(
{
fmt => "Hello %(name)s! Today you are %(age)d years old.",
}
);
my $person1 = Person->new(name => "Larry", age => 24);
my $msg1 = $formatter->format({args => { obj => $person1 }});
my $person2 = Person->new(name => "Rachel", age => 30);
my $msg2 = $formatter->format({args => { obj => $person2 }});
Look at her go π
π¦ DESCRIPTION π¦
So this module is a sub-class of Text::Sprintf::Named, right? And the whole ~thing~ is that the variables sitting inside the sprintf fields β you know, the ones that look like "%(varname)s" β get read from the accessors (or honestly any other function, no gatekeeping) of the current object.
It's giving "named placeholders but make them object methods." Iconic behaviour honestly. π
πΈ METHODS πΈ
$formatter->calc_param()
Over-riding the behavior of the equivalent one in Text::Sprintf::Named. (Periodt. That's the whole description.)
$formatter->obj_format($object, \%args)
Formats based on the accessors of the object $object. And, ngl, I don't think %args is used in any way. π Like it's just... there. Sitting pretty. Not doing much. We love a decorative parameter.
π AUTHOR π
Written by Shlomi Fish</>, <http://www.shlomifish.org/>.
Shoutout to the author, fr fr π«Ά
π LICENSE π
This file is licensed under the MIT X11 License:
http://www.opensource.org/licenses/mit-license.php
Bestie, if you're gonna reuse this, go read the actual license text at that link. Don't just vibe off my summary, okay? π
π₯ SEE ALSO π₯
Text::Sprintf::NamedTest::Run
And that's the page, babes β¨ This was Test::...essors(3pm) β the manual page name got the βοΈ treatment but you know who she really is β from the perl v5.42.0 era, dated 2025-07-25, under the User Contributed Perl Documentation. Slay, stay hydrated, and may all your sprintf fields resolve correctly π
π
π¦ where this page comes from
- fedora 43: perl-Test-Run 0.0306-3.fc43 Β· (GPL-1.0-or-later OR Artistic-1.0-Perl) AND GPL-2.0-only AND MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms