Text::Template.pm (current version: 1.44; last updated 2003-04-29)

Text::Template is a module for filling in templates. A template is a file or a string that has bits of Perl code, called program fragments, embedded in it. Program fragments are delimited by curly braces. They can be simple variable references like {$var} or complicated programs that define and call functions and assemble big chunks of HTML text. When a template is filled in, the program fragments are executed, and each is replaced with the values they compute, so for example {$var} is replaced with the value of $var. Parts of the template that are not program fragments are returned verbatim.

This is useful for generating form letters, CGI program output, and many other kinds of text. For example, you might have a form letter like this:

	Dear {$title} {$lastname},

	It has come to our attention that you are delinquent in your
	{$monthname[$last_paid_month]} payment.  Please remit
	${sprintf("%.2f", $amount)} immediately, or your patellae may
	be needlessly endangered.

			Love,

			Mark "{nickname(rand(100))}" Dominus

The result of filling in this template is a string, which might look something like this:

	Dear Mr. Gates,

	It has come to our attention that you are delinquent in your
	February payment.  Please remit
	$392.12 immediately, or your patellae may
	be needlessly endangered.


			Love,

			Mark "Vizopteryx" Dominus

To join a low-volume mailing list for Text::Template announcements, send a blank mail message to mjd-perl-template-subscribe@plover.com, or fill in the form below:

Your address

What's new in 1.44

What's new in 1.43

What's new in 1.42

What's new in 1.41

What's new in 1.40

What's new in 1.31

What's new in 1.23

What's New in 1.20

What's New in 1.12

What's New in 1.11

What's New in 1.10

What's New in 1.03

What's New in 1.0


Return to: Universe of Discourse main page | What's new page | Perl Paraphernalia

mjd-perl-template@plover.com