http://qs321.pair.com?node_id=89244


in reply to Separation of content and code

Well, I think your question is a little unclear to me, but I'll try and do a spot of guesswork and shoot in a few directions... just a reminder: try to preview before you submit a question, a bit of punctuation and a few paragraph <p> tags here and there could help a lot

If I understand correctly, your scenario is that you've written a CGI script, which generates HTML (using print statements or heredocs)..

Now this posting is a great place to start reading on why you need to put your HTML in a different file.. quite simply, you want to separate your code from your presentation (HTML) because that makes it easier to maintain... if someone asks you to do minor changes to the HTML, then you need to dig through all of your code to find out the place to change, and you could actually break some of your code in the process...

Another thing, if you separate your HTML into another file, someone who doesn't know Perl well, but who does know HTML could actually figure out what to do, and fix it..

Another option that I think you mention is to generate an HTML file and display that on the webserver, rather than a CGI script.. (correct me if I didn't guess right).. well, you could do this, but then your content would no longer be dynamic, it would have to rely on your CGI script executing periodically and regenerating your HTML file.. if you need to display something that doesn't change very often, or if it does not need to be customized by individual viewers of your site (for example, a site like Perlmonks has to be customized and dynamic because different users have different views of the content on the site), then generating static HTML pages will mean that the webserver doesn't have a lot of overhead running a CGI script..

I hope this answered your question.. if you need any clarification or if I didn't answer what you needed to know, please reply on this thread...