As promised, I wrote and released Text-Sprintf-Named onto the CPAN. This is an implementation of a Python-like sprintf with named conversions. So you can do my $formatter = Text::Sprintf::Named->new({fmt => 'Hello %(name)s! You have $%(money)04d in your bank account!'); and then $formatter->format({args => {name => "Joey", money => 350}}) and get 'Hello Joey! You have $0350 in your bank account!' in return.
Now that I look at its POD again I see that the code in the synopsis is wrong. I guess I'll have to release version 0.01001 soonishly. If you find this module useful, that's good, and if not, I hope I haven't made your situation any worse. I wrote it because I thought it may prove useful for a Test::Run plugin, so necessity was the mother of implementation in this case.
Cheers all, and a Happy Thanksgiving to all Americans.
Text vs. String (Score:2)
BTW I got my choice for "String" from String::Format [cpan.org].
Oh yeah: I'm planning to support numerically indexed parameters, like
%2$.3fsto format the second parameter (the partRe: (Score:2)
When I first came up with the idea of having a sprintf with named conversions, I wanted to call the module Text-Sprintf-Named. That was before I learned about your efforts, and when I implemented it, I followed my initial mental inertia.
To quote Larry Wall [perl.org]: "Th
Re: (Score:2)
When I first came up with the idea of having a sprintf with named conversions, I wanted to call the module Text-Sprintf-Named. That was before I learned about your efforts, and when I implemented it, I followed my initial mental inertia.
Oh, OK. Your reasons are as good as mine, so I will not say you're wrong. Plus, if you name your module after mine, it would seem like yours is based on mine, while it is not.
Anyway, now that I know it exists, I'll keep an eye on it, and possibly we can try to synchronize them, so they work well together, if that looks desirable.
Re: (Score:2)
Indeed. This is one reason I believe String-Sprintf is not a good enough name for the module you wrote, because there may be other String-Sprintf-* modules, with different takes on an enhanced sprintf-like functionality. I used *-Sprintf-Named to indicate something on the enhancement I intended the module to have.