Helpful Information
 
 
Category: Perl Programming
template parsing

My previous post didn't make much sense when i read it afterwards, so i rewrote it:

What i need is a script that reads a file, searches for a & and takes the first word which comes after it and puts that word in a variable.
Example:

(This is part of the template)
<img src="&ImageLogoLocation">

After script is run a variable should contain
the string: ImageLogoLocation

Thanks in advance

I can't really help you, but the "Perl Cookbook" from O'Reily is a great book with practical perl examples. If you want to make a great $40.00 investment I would suggest this book. It has information on template parsing.

I can suggest general aproach.
1. You need define rule for parsing your template. And use appropriated mechanism to seaching positions for substitutions and making it (If you have decided to seach '&' as start position what will define the end of string for substitution, this is the full name of variable).
2. Read template, look for strings for substitution, fill out requred position.
(You can use Hash, database, etc for storing and getting desired value of desired variable)
3. Print to stdout (in your case clients webpage) the strings with concatanating of initial static contents and filled by values variables.
Hope it helps.
One of other general aproachs is to invite somebody to write script.

Thanks for your ideas. I think i'll look into perl regular expression tutorials http://www.devshed.com/Talk/Forums/smile.gif

Try the HTML::Template module.


<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by d0g1e:
Thanks for your ideas. I think i'll look into perl regular expression tutorials http://www.devshed.com/Talk/Forums/smile.gif[/quote]

I like the way everybody dodged the question there http://www.devshed.com/Talk/Forums/tongue.gif
for <img src="&ImageLogoLocation">:

if($string=~m/&(.*?)"/){$var=$1}
print $var;

Would print "ImageLogoLocation"










privacy (GDPR)