in reply to Forcing Variable Interpolation

Am I understanding this correctly? The template is a file of your own creation, and using perl you read each line of the template, look for $header (for example), and if you find it, drop in your data? If so, you're reinventing the wheel ;) There's a nifty module called HTML::Template that can help you.

A template with HTML::Template takes the following format:

<html> <head> <title><TMPL_VAR NAME=TITLE></title> </head> <body bgcolor="#FFFFFF"> <TMPL_VAR NAME=BODYTEXT> </body> </html>
Each TMPL_VAR entry is similar to $header, $footer, etc. You can then populate your template as easily as this:
my $tmpl_frame = HTML::Template->new(filename => "/path/to/my/template.tmpl"); $tmpl_frame->param( TITLE => "Sample Page", BODYTEXT => "This is some text." ); print $tmpl_frame->output;
Cool, eh? ;)

Hope this helps,
MrCromeDome

Replies are listed 'Best First'.
Re: Re: Forcing Variable Interpolation
by fallenmonkey (Initiate) on May 09, 2002 at 18:45 UTC
    Woohoo! For some reason I didn't even think about using an existing module! Thanks so much, that makes so much more sense :P

    -- The Fallen Monkey