Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

(jeffa) 3Re: CGI Benchmarks

by jeffa (Bishop)
on Jan 25, 2001 at 22:22 UTC ( #54315=note: print w/replies, xml ) Need Help??

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.


(the triplet paradiddle)

Replies are listed 'Best First'.
Re: Re: Re: Re: CGI Benchmarks
by skeight (Novice) on Jan 26, 2001 at 02:57 UTC
    First off, I am the only person working on this script and chances are no-one else will ever maintain it other than me, so I can pretty much do whatever I want

    Here's an example of what I am doing:
    ... print "welcome ",$username, "your email address is ",$email; open(HTML,"index.da1"); while(<HTML>){print$_;} close(HTML); print "your manager is ",$manager; open(HTML,"index.da2"); while(<HTML>{print$_;} close(HTML);
    basically I print out some information from the database, then a whole wack of html code (index.da1) and then print out some more info from the database then a whole wack more of html (index.da2).

    obviously this is a very small example compared to what I am actually doing, but the basic idea is there.
    do you think it would be quicker just to have all the html 'embedded' into the perl? even though this would make the script well over 7500 lines long? Does that make a difference (file length)?


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://54315]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2022-08-16 09:33 GMT
Find Nodes?
    Voting Booth?

    No recent polls found