|Just another Perl shrine
Re^3: inserting HTML file in a PERL scriptby wfsp (Abbot)
|on May 29, 2005 at 11:43 UTC
To add to the advice from tchatzi.
The first time I came across Perl I was in a very similar situation to yourself. Perhaps the experiences I had maybe helpful.
Only make one small change at a time. You'll stand a better chance of having something that still works.
A point often made is that, as much as possible, keeping code and HTML separate makes maintaining both easier. A first step could be at least moving it all to the end of the script. Have a sub that returns the HTML.
The next step I took was to replace the variable with an HTML comment.
and then the code would look something like
The advantage here is that Frontpage can happily use the HTML.
After that it wasn't long before the HTML ended up in a file.
This way you can maintain the HTML in FrontPage.
Once you get to this stage you start to realise you have trod a well worn path! Many have gone before you. As scooterm pointed out above there are many template modules available. I now use HTML::Template and find it excellent.
There are many other aspects of cgi scripts you may want to consider (there is a very good module for that too).
Hope this is of help. If after looking through the docs you still hit some snags (I hit plenty) come back, show what you were trying to do, what you have tried, what you expected. If you do that I have always found the monks very helpful.
update: Corrected name of sub in code snippet