This module provides a single function, which implements a simple ``text macro'' mechanism for assembling templated text strings.

$expanded_text = text_builder( $base_text, @exprs )

Returns a modified copy of $base_text using rules from the @exprs list.

The @exprs list may contain any of the following:

A string, in which any '*' characters will be replaced by the base text. The interpolated string then replaces the base text.

A code-ref, which will be called with the base text as its only argument. The result of that call then replaces the base text.

A hash-ref, which will be added to the substitution hash used in the second pass, below.

An array-ref, containing additional expressions to be treated as above.

After any initial string and code-ref rules have been applied, the hash of substitution rules are applied.

The text will be searched for occurances of the keys of the substitution hash, which will be modified based on the corresponding value in the hash. If the substitution key ends with '{}', the search will also match a balanced block of braces, and that value will also be used in the substitution.

The hash-ref may contain the following types of rules:

'string' => 'string'

Occurances of the first string are to be replaced by the second.

'string' => code_ref

Occurances of the string are to be replaced by the results of calling the subroutine with no arguments.

'string{}' => 'string'

Occurances of the first string and subsequent block of braces are replaced by a copy of the second string in which any '*' characters have first been replaced by the contents of the brace block.

'string{}' => code_ref

Occurances of the string and subsequent block of braces are replaced by the results of calling the subroutine with the contents of the brace block as its only argument.

'string{}' => hash_ref

Occurances of the string and subsequent block of braces are replaced by using the contents of the brace block as a key into the provided hash-ref.