in reply to Parsing Templates

s/%tag%/$value/g if defined $value;
If your variables aren't declared, you could copy them to an hashref and pass this hashref to your template parser.
$hash = {key1 => 'value', key2 => 'value'}; ... foreach my $key (keys %$hash) { s/%$key%/$hash->{$key}/eg; }