in reply to Re: Populating CGI popup_menu via DBI
in thread Populating CGI popup_menu via DBI

Thanks for your reply. You're right about the efficiency not being critical here, but seeing potentially inefficient code like that always puts me on alert. As I see it, the following steps are needed:

  1. Fetch data from DB
  2. Write data into hash
  3. Loop through hash to get labels
  4. Loop through hash to get values
  5. Print HTML

With many other functions, like the pop-up menu where labels and values are the same that I showed above, you can skip steps 3 and 4 and go straight from the DB to the CGI printing. Not only that, it just feels like a lot of code! I had been hoping that there was a more concise idiom somewhere out there waiting to be discovered....

-Tats
  • Comment on Re: Re: Populating CGI popup_menu via DBI

Replies are listed 'Best First'.
Re: Re: Re: Populating CGI popup_menu via DBI
by KPeter0314 (Deacon) on May 30, 2003 at 14:34 UTC
    I fully agree with jsegal on this, the performance of accessing this small hash twice can't be much. If you have more that a cople dozen entries in the popup it can become unmanageable for the user. I suppose it could be a concern for a heavily laden server though.

    It is probably possibe to avoid these steps, but I it would have to be one of two ways:

    1. Not using the CGI module, or
    2. Using techniques known only to the maintainers of the CGI module

    I'll also add that the you hinted at a worry about the load on your DB. That also won't be an issue as you are only sucking the data into the hash once.

    Good luck with your app. It looks like you are concerned with proper coding and that can't be bad.

    -Kurt