Help for this page

Select Code to Download


  1. or download this
    $template_file_string =~ s/\$(\w+)/${$1}/g;
    
  2. or download this
    my %vars = (
        title => 'Foo Bar'
    ...
    my $template = q(<h1>$title</h1>);
    
    $template =~ s/\$(\w+)/$vars{$1}/eg;
    
  3. or download this
    use Text::Template;
    
    ...
        or die "Couldn't construct template: $Text::Template::ERROR";
    
    my $text = $t->fill_in(HASH => \%vars);