Perl Monk, Perl Meditation | |
PerlMonks |
Re: Transfering Varriablesby dvergin (Monsignor) |
on Feb 25, 2002 at 23:38 UTC ( [id://147428]=note: print w/replies, xml ) | Need Help?? |
Use a hash to store the substitution values from
the one source. Then just sub 'em in. You don't give
any information about the source of the values to use
for replacements. So I made some assumptions for
this quick demo.
You will need to adapt this to make it more robust and to make it fit your need but this should give you the general idea. For a more elegant approach to the substitution, replace entire process fields "for" loop with this: $template =~ s/%(\w+)%/$values{$1}/g; If you are going to get serious about this, I suggest you look into one of the template modules.
------------------------------------------------------------
In Section
Seekers of Perl Wisdom
|
|