in reply to Re: Inserting a Value
in thread Inserting a Value

Hi Ovid, thank you for your reply. The value for $name is already set. I'm just trying to figure out how to get the script to recognize and insert the preset $name value within the $body content.

Replies are listed 'Best First'.
Re: Re: Re: Inserting a Value
by grep (Monsignor) on Apr 17, 2003 at 19:12 UTC
    Sounds like you want a templating system.

    Check out these modules. All 3 are excellent.:

  • Template Toolkit.
  • HTML::Template
  • HTML::Mason

    How you would use Template Toolkit:
    Create a template 'my_template.tmpl':

    <html> ... <body> Hello [% name %], how are you today </body> </html>

    Your perl code:

    #!/usr/bin/perl -w use strict; use Template; my $file = 'my_template.tmpl'; my $vars = { name => "Schmidy" }; my $template = Template->new(); $template->process($file, $vars) || die "Template process failed: ", $template->error(), "\n";

    You get to seperate your presentation from your code. No more digging through html in your perl code.

    grep
    Mynd you, mønk bites Kan be pretti nasti...