Gossamer Forum
Home : General : Perl Programming :

Easier way to do this?

Quote Reply
Easier way to do this?
Ok, let's say I have a template file. In the template file are different tags ($tag1, $tag2, etc.)

I want it to open the template file, replace the tags with the data of the tag.

For example, I have for each tag:

open (NAME,"$templates_dir/message_index.html");
@html=<NAME>;
close (NAME);

foreach $line (@html) {
$line =~ s/\$tag1/$tag1/g;
$line =~ s/\$tag2/$tag2/g;
$line =~ s/\$tag3/$tag3/g;
}

print @html;

Is there an easier way to do this?

------------------