my %vars = (    test => "Perl", ); my $content  = ""; my @template = ("Blablabla\n", "<% test %>\n", "blablabla\n"); foreach my $row (@template) {    $row      =~ s/<% ([A-Za-z0-9]+) %>/$vars{$1}/gix;    $content .= $row;    print $row; }