http://qs1969.pair.com?node_id=54315


in reply to Re: Re: CGI Benchmarks
in thread CGI Benchmarks

Sorry I am a bit late on this thread.

Without seeing the whole context of your example, I am prone to say that you are delving into serious overkill. Why use a Perl script to deliver the contents of a text file without doing anything to it? HTTP is perfectly capable of doing this for you. :)

open(HTML,"index.da1"); while(<HTML>){ # do something to $_ print $_; } close(HTML);

Yes, that is slower than embedding the code, because you have to open a file, as well as print each line. But, if you are actually doing something to each line, or even just a few special lines - then it is a viable solution. Of course, if you are just testing the waters, then that is certainly understandable.

But that's not my point - database access will make your speed concerns with your current program seem very trivial.

Which brings me to my real point - "embedding" HTML into a Perl script really only has one major issue in my books - MAINTAINABILITY!!

If you are the only user of this script, don't worry about it. But, if you are coding for the good of a larger project, one that has HTML content writers and programmers - then you will want to seperate the HTML from the Perl.

Generally, Perl programmers don't want to have to concern themselves with the details of HTML layout - and HTML writers usually can't understand Perl code.

My first real assignment after graduating was a Cold Fusion project. My HTML was embedded in the Cold Fusion files like a cancer - and when it came time to tweak the position of this or that graphic, guess who had to do it? Me!! If I was smart, I would have seperated the HTML code completely, so that the HTML writers could tweak without having to be scared that they would screw everything up.

If you really want to put your HTML code in separate files, look into HTML::Template, it is well worth your time.

Jeff

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
F--F--F--F--F--F--F--F--
(the triplet paradiddle)