App::vaporcalc::FormatString - Templated string formatter
my $things = "some very special"; my $formatted = format_str( "My %string% with %this% var", this => $things, string => "cool string", ); ## -> My cool string with some very special var
A tiny string formatter.
Exports a single function: "format_str"
Takes a string and a hash (or hash reference) mapping template variables to replacement strings.
The replacement variables can be coderefs returning a string:
format_str( "My string with %code", code => sub { my ($match, $orig, $callback) = @_; . . . return "Some string replacing variable $match" }, );
The code reference will receive the matching variable ("code"), the original matched string ("%code" in the above example), and itself as its respective arguments.
Jon Portnoy <avenj@cobaltirc.org>
To install App::vaporcalc, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::vaporcalc
CPAN shell
perl -MCPAN -e shell install App::vaporcalc
For more information on module installation, please visit the detailed CPAN module installation guide.