Text::Sprintf::NamedSprintf-like function with named conversions | |
Download |
Text::Sprintf::Named Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Shlomi Fish
- Publisher web site:
- http://search.cpan.org/~shlomif/
Text::Sprintf::Named Tags
Text::Sprintf::Named Description
Text::Sprintf::Named is a Perl module that provides a sprintf equivalent with named conversions. Named conversions are sprintf field specifiers (like "%s" or "M") only they are associated with the key of an associative array of parameters. So for example "%(name)s" will emit the 'name' parameter as a string, and "%(num)4d" will emit the 'num' parameter as a variable with a width of 4.SYNOPSIS use Text::Sprintf::Named; my $formatter = Text::Sprintf::Named->new( {fmt => "Hello %(name)s! Today is %(day)s!"} ); # Returns "Hello Ayeleth! Today is Sunday!" $formatter->format({args => {'name' => "Ayeleth", 'day' => "Sunday"}}); # Returns "Hello John! Today is Thursday!" $formatter->format({args => {'name' => "John", 'day' => "Thursday"}}); # Or alternatively using the non-OOP interface: use Text::Sprintf::Named qw(named_sprintf); # Prints "Hello Sophie!" (and a newline). print named_sprintf("Hello %(name)s!\n", { name => 'Sophie' }); # Same, but with a flattened parameter list (not inside a hash reference) print named_sprintf("Hello %(name)s!\n", name => 'Sophie');Product's homepage
Text::Sprintf::Named Related Software