Rule #1: perl -wT,use strict, use CGI; This will never hurt you and cna only serve to safeguard your CGI. Turn off POST uploads and set POST_MAX.
For a needed speed improvement, check out mod_perl or FastCGI which will boost your performance by caching your CGI.
Tip #3: While you're using DBi, you might as well use the "?" which allow you throw in data along the way in your query. In this manner, you could probably conactenate your entire query mess into one or two lines. If you want a real speed improvement, you can read from the dbengine one at a time, see the DBI docs. While this eats up the same memory in the dbengine, the user will see results more quickly which is probably what you want. That way, you can also store count up the first ten and stop automatically instead of reading in the first ten and then displaying them. Anyway, your SQL statement is lousy since it requests all statements, displays the first select few and doesn't even bother to cache the next few. Most dbengines have support for "get me the first ten matches" or something like that. If it doesn't a trick may be to read in all of the matches (simultaneously displaying them), cache them (minimally in timed-out tmp file but better using FastCGI) and the next next theuser comes around, he has his data waiting for him. Currently, you are wasting alot of user time just reading in data from the dbegine that you read only seconds before! As your site grows, the decrease in dbengine performance will be VERY visible. The brand new CGI::Cache is also a nifty module that i would strongly recommend for integration into your script. If you're interested in further reading into the FastCGI/mod_perl issues, click here. (**for some reason, fastcgi.com seems to be down at the current time 11amEST10-5-00 so check it out perhaps a bit later.) But whatever you do take into consideration and integration, it will take some time. Some of your script needs some big rewrites. And as I and tilly were discussing before, this is "real problem" (i.e. nothing to ignore- security, performance, resource waste). If you'd rather not write it yourself, do a search for "DBI search engine" at a few sites and take the optimized code that we've been discussing. One more thing (I know I'm long-winded)- you should use the -compile option in your use CGI qq/.../; statement. This will precompile most of your HTML prints so you end up with something even more decent.
AgentM Systems or Nasca Enterprises is not responsible for the comments made by AgentM- anywhere.

In reply to Re: Help required to improve code by AgentM
in thread Help required to improve code by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.