Posted by Peter Palfrader aka Weasel on 1999-10-11
On Mon, Oct 11, 1999 at 04:47:52AM +0200, Frank Hale wrote:
> What am I doing wrong?
You checked if it included the sequence, if yes, print hello
world. afterwards print the line.
What I do is this:
while ($template =~ /%%([^%]*)%%/)
{
$template =~ s/%%([^%]*)%%/( defined($tmp{$1}) ? $tmp{$1} : '')/ge;
};
where template is an html file and %tmp a hash with the variables to
replace.
the variables in the template are surrounded by 2 % each.
example:
template: This is my msg: %%msg%%. done.
%tmp: 'msg' => 'Hello world'
after the loop the template looks like this:
This is my msg: Hello world. done.
now you can print it.
HTH
--
Weasel http://www.cosy.sbg.ac.at/~ppalfrad/
PGP encrypted messages prefered. See my site or finger -l ppalfrad
A friend is someone who knows the song in your heart and
can sing it back to you when you have forgotten the words.
Sponsored by Wrox Press - www.wrox.com. Programmer to Programmer (TM)
Previous post | Next post | Timeline | Home