I’m writing a web application in Perl. It has a form containing contact information, the code for which is currently laid out something like this:
Later on I print $form_htm (amongst other things) to display the webpage.$form_htm = <<EOF <input value="$in{firstname}" name="firstname"> <input value="$in{surname}" name="surname"> ...etc... EOF
The above is working for me, and the fields are interpolated as expected.
However, I’d like different organisations who use this application to be able to have a different layout for their fields. Some fields won’t apply to some organisations, and some organisations will want different sizes (on the webpage) for fields than others.
So, I thought I’d store the HTML for the form in a database (different versions in different records for different organizations).
But because the HTML is not stored in the script, the fields (like $in{firstname}) are not interpolated, so the variable names themselves are ending up on the webpage, (which is not quite the look I’m after).
Any recommendations on how I should get these variables to be evaluated in this context? (First thing that came to mind is eval(), but that seems aimed at evaluating expressions, not variables mixed in with a lot of other text.)
Or can you suggest a better approach which would allow different organisations to have different form layouts?
Edit: I have also posted this question on StackOverflow, but would like to get other opinions.
Thanks.
tel2
In reply to Interpolation of variables in stored HTML by tel2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |