Test::...essors(3pm)

πŸ“¦
version 0.0306 Β· 2 versions
, in fedora 43

πŸ’– 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::Named
  • Test::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