Perl::Hypotext - evaluate perl code embedded in text.
use Perl::Hypotext; # you can any argumnets at initialization my $t = Perl::Hypotext->new({}); my $template = q{ Yo nombre es [- $name -]. I am [- $age -] years old. }; # initialize a couple vars in package 'main' my $name = 'Steve'; my $age = 31; # parse defaults to package 'main' (unless a hash has been loaded) print $t->parse({ text => $text }); # or...use a hash ( slower, but MUCH easier to work with ) my %hash = ( name => 'Steve', age => 31 ); print $t->parse({ text => $text, hash => \%hash }); # ...or however you like it, as long as text and hash or package name # is loaded before or when parse() is called.
Perl::Hypotext a module for evaluating perl embedded in text. The perl can be evaluated under a specified package, or under a package built from a provided hash.
Perl::Hypotext
Initializes a Perl::Hypotext object. Pass parameter as a hash reference. Optionally pass: delimiters, hash, package, text, file, inline_errs (see descriptions below).
Installs values identified by a given hash reference into a package under which to evaluate perl tokens.
Install the text to be parsed as the template.
Specify a file containing the text to be parsed as the template.
Specify how to handle error messages generated during the evaluation of perl tokens. a true value = inline, a flase value = ignore.
Set the package name under which to evaluate the extracted perl. If used in concert with a hash, the package name must be set prior to installation of a hash.
Runs the parser. Optionally accepts parameters as specified for new();.
Returns the fully parsed and evaluated text.
0.25 - Name Change: Was stomping on a Template Toolkit module. Doh! 0.24 - Bug Fix: Internal package cleanup now works correctly when using hashes. 0.23 - Can now specify a package underwhich to install a hash (was explicitly 'Safe'). This also means that the package name must be set prior to or at the time of installation of a hash, or not at all.
Changed default delimiters to '<?' and '?>' (was '[-' and '-]').
Steve McKay, steve@colgreen.com
Copyright 2000-2001 Steve McKay. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Parse::Tokens, Text::Template, Text::SimpleTemplate
Parse::Tokens
Text::Template
Text::SimpleTemplate
To install Perl::Hypotext, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl::Hypotext
CPAN shell
perl -MCPAN -e shell install Perl::Hypotext
For more information on module installation, please visit the detailed CPAN module installation guide.